question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

reload vs refreshModel

See original GitHub issue

Hello,

I was under the impression that the reload option was to replace the refreshModel on the route, but it seems it does not.

It would be nice to actually regroup the route query params options under the same parachute config within the controller: https://emberjs.com/api/ember/2.14/classes/Ember.Route/properties/queryParams?anchor=queryParams

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
mwpastorecommented, Jul 14, 2017

@juggy ember-parachute moves all the query param handling to the controller, and you have to manage your data fetching in the queryParamsDidChange controller hook. The route loses all information it has about the query params; it doesn’t need it anymore.

I’m using a construct like this to refresh the model when certain query params change:

const myQueryParams = new QueryParams({
  foo: {
    refresh: true // N.B. it's `refresh', not `reload'
  },
  bar: {
    refresh: false
  }
});

export default Ember.Controller.extend(myQueryParams.Mixin, {
  queryParamsDidChange({ shouldRefresh, queryParams }) {
    if (shouldRefresh) {
      // this will only fire if the `foo' query param changed
      this.transitionToRoute({ queryParams }); // or replaceRoute
    }
  }
});

This lets you preserve your existing model hooks and loading behavior while leveraging ember-parachute.

0reactions
allthesignalscommented, Jun 25, 2018

This does not seem possible to me - you cannot refresh the route with new QPs from the same route using transitionToRoute.

The alternative seems to be to use a route action so you have access to this.refresh, but if you have to do this in a child route, it seems like you’ll get “unhandled action” errors when navigating from a parent route:

// routes/application.js
@action
refreshModel() {
   this.refresh();
}

// controllers/show-geography.js
...
  queryParamsDidChange({ shouldRefresh }) {
    if (shouldRefresh) {
      // this will only fire if the `foo' query param changed
      // this.send('refreshModel');
      this.send('refreshModel');
    }
  }
...

My problem with this approach is that it’s unclear which model will be getting refreshed. If I have an application.js model, will only that be refreshed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Refresh ember model - Stack Overflow
To refresh your ember model you can use this.refresh(); . To rollback all the attributes when you leave the route you can use ......
Read more >
Reloading model when using transitionToRoute approach
Hey, Assuming i'm currently in route 'foo', it sometimes make sense to requesting a model re-load for the same transition, but invoking ...
Read more >
Force Ember Data to reload data from backend API
This is Ember Data's default strategy for requesting data records (either findRecord or findAll ):. If it is not loaded, load it; If...
Read more >
Tweaking UI Behavior with Ember Data Queries
We define a refreshModel() action method that just calls the refresh() method. Since refresh() isn't an action, we can't access it directly from ......
Read more >
Rapid Refresh (RAP)
The Rapid Refresh is a high-frequency weather forecast (numerical weather prediction) and data assimilation system, planned to replace the RUC in NCEP ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found