Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4831

Refreshing Application Data when switching routes

$
0
0

@toinecl wrote:

I have a multi-user ember application where the back-end (REST API) keeps track of progress of the entire team. So, I have done the following:

adapters/application.js

import DS from 'ember-data';

export default DS.RESTAdapter.extend({
  namespace: 'cws/api',
  host: '..',
});

routes/application.js

import Route from '@ember/routing/route';

export default Route.extend({
  model() {
    return Ember.RSVP.hash({
      currentProgress: this.store.findRecord('progress', 1, {reload: true})
    });
  }
});

templates/application.hbs

<div>{{model.currentProgress.percentage}}%</div>

Whenever someone switches routes, I’d like to refresh the model.currentProgress value. I tried doing that by adding a refresh() or reload() to all the other routes’ js files, but that causes an infinite loop.

How would you do this?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4831

Trending Articles