diff --git a/app/models/entity.js b/app/models/entity.js index 8b945cb..b5f469c 100644 --- a/app/models/entity.js +++ b/app/models/entity.js @@ -3,13 +3,5 @@ import DS from 'ember-data'; export default DS.Model.extend({ type: DS.attr('string'), - properties: DS.hasMany('property'), - - /*poll: function() { - var _this = this; - Ember.run.later( function() { - _this.reload(); - _this.poll(); - }, 1000); - }.on('didLoad')*/ + properties: DS.hasMany('property') }); diff --git a/app/routes/entities.js b/app/routes/entities.js index 3ac0567..567b3a3 100644 --- a/app/routes/entities.js +++ b/app/routes/entities.js @@ -3,5 +3,22 @@ import Ember from 'ember'; export default Ember.Route.extend({ model() { return this.store.findAll('entity'); + }, + + afterModel() { + // first time call poll + Ember.run.later(this, function() { + this.refreshEntities(); + }, 500); + }, + + refreshEntities: function() { + // fetch new data from server + this.store.findAll('entity'); + + // reschedule refresh + Ember.run.later(this, function() { + this.refreshEntities(); + }, 500); } }); diff --git a/config/environment.js b/config/environment.js index fb14383..3072554 100644 --- a/config/environment.js +++ b/config/environment.js @@ -38,11 +38,11 @@ module.exports = function(environment) { // ENV.APP.LOG_TRANSITIONS_INTERNAL = true; // ENV.APP.LOG_VIEW_LOOKUPS = true; - ENV.APP.API_HOST = 'http://localhost:4200'; + //ENV.APP.API_HOST = 'http://localhost:4200'; ENV['ember-cli-mirage'] = { - enabled: true - //enabled: false + //enabled: true + enabled: false } }