Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing query in setup hook #77

Open
sevab opened this issue Feb 27, 2019 · 2 comments
Open

Changing query in setup hook #77

sevab opened this issue Feb 27, 2019 · 2 comments

Comments

@sevab
Copy link

sevab commented Feb 27, 2019

I'm doing query param validation on page load in the setup hook:

setup({ queryParams }) {
  if (this.isPastDate(queryParams.date)) {
    this.set('date', null);
  }
  this.fetchData(queryParams);
}

While the 'date' controller value updates, the URL still has the old value for date.

Is setup() hook not ideal for changing query params? Wanted to avoid using beforeModel() on the route, since this is more concise.

@sevab
Copy link
Author

sevab commented Feb 27, 2019

Resetting individual queryParams in beforeModel() is actually broken as well right now (emberjs/ember.js#14606), so hoping will find a way to get this to work.

@sevab
Copy link
Author

sevab commented Feb 27, 2019

Current workaround:

setup({ queryParams }) {
  if (this.isPastDate(queryParams.date)) {
   // ensure fetchData receives correct params in current run-loop
    queryParams.date = null;
    next(() => { this.set('date', null); });
  }
  this.fetchData(queryParams);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant