How do I get fresh data from the server/DS in ember without reloading a page?
here is the updated component for ember
import Component from '@ember/component';
import { set } from '@ember/object';
import { inject as service } from '@ember/service';
import { alias } from '@ember/object/computed';
export default Component.extend({
router: service(),
init() {
this._super(...arguments);
let alertColor = this.alertColor;
this.refreshInterval = setInterval(() => {
if (this.isDestroyed || this.isDestroying) return;
this.router.refresh();
}, 3_000);
}
})
this is the route... I think. There are other ones but this I think is the one it uses. Im not positive though. Theres also a component which i deleted because Stackoverflow said there wasnt enough details and mostly code...so thats why Im adding all this text here
import AddThis from '../mixins/add-this';
import getQueryVariable from '../utils/get-query';
import Route from '@ember/routing/route';
import { get } from '@ember/object';
export default Route.extend(AddThis, {
model: function(args) {
this._super(...arguments);
return this.store.findRecord('landing-page', args.id);
},
setupController: function(controller, model) {
this._super(...arguments);
const href = get(model, 'uri') +
window.location.search +
window.location.hash,
id = getQueryVariable('id');
if (id && !isNaN(id) && get(model, 'cardPageType') === '2') {
this.transitionTo('image', get(model, 'id'), 0, id);
}
// @TODO Not 100% clear on what this is for
if (get(model, 'uri')) {
window.history.replaceState('', get(model, 'title'), href);
}
},
actions: {
goToVideo: function(id) {
this.transitionTo('video', id);
},
},
});