mardi 12 janvier 2021

How to know when Ember query params have loaded without using Route?

I am working on a 3rd party Search component that filters based on query params in the URL. If no query params are provided, a default search is made on init().

I am having an issue because at the time my component init() runs, the query params values have not yet been assigned.

On previous occasions, I have been able solve this problem using Route hooks, for example

setupController() {
    controller.loadSearchResults()
  }

because at the point setupController is run, the query params have their correct values.

On this occasion, due to it being a third party library I only have access to a controller and component. Is there any way to know/wait for queryParams to be assigned outside of a Route? I'm hoping for some kind of lifecycle hook such as Controller.didLoadQueryParams

The Ember docs seem to be lacking in this area as discussed in https://github.com/emberjs/rfcs/issues/196




Aucun commentaire:

Enregistrer un commentaire