Background
I'm more used to Rails but trying to improve my client side javascript by switching to an MVC. Ember seems like a good fit for me (it has good integration with Rails and a similar convention over configuration approach).
I'm using Ruby 2.0.0, Rails 4.0.0 & Ember 1.0.0-rc6.3 so realise that this is all pretty new.
However, so far I've managed to display data from the database via a JSON API without any problems and it is working great.
Question
I'm currently struggling with updating the data when it changes on the database though.
My initial approach is to begin by using polling to keep the client data updated as the background job processes and updates the database (I would like further down the line to try SSE and Live to make this process better - but polling to start with).
The polling aspect is working fine like this in my controller
App.AnalysesController = Ember.ArrayController.extend
loaded: (->
setTimeout (=> @poll()), 1000
).observes('content.isLoaded')
poll: ->
console.log @get('content')
@get('content').reload()
I thought i'd found a solution to my issue with this commit:
https://github.com/emberjs/data/commit/278a0b863f0b1b2494fe2319ac12be6167195f6b
Whereby you can reload the model.
Unfortunately I am getting this error when I try...
Uncaught ReferenceError: reload is not defined
Which I don't understand because it looks like my content is of the right format and is not updating
Class {type: function, store: Class, isUpdating: false, toString: function, constructor: function…}
However - this works...
App.AnalysesController = Ember.ArrayController.extend
loaded: (->
setInterval (=> @poll()), 1000
).observes('content.isLoaded')
poll: ->
@set('content', App.Analysis.find())
Though it feels wrong to me - I should be using the model not duplicating the find query surely?
If anyone has any ideas why reload is not working i'd really appreciate it, as i've hit a bit of a wall but up until now have been enjoying learning Ember.
Thanks!