ember.js - Socket.IO with Ember and Ember-Data -


i've been poking around , can't find date examples of ember (1.0.0-rc.1) , ember-data(revision 11) use socket.io. i've tried this.

app.applicationroute = ember.route.extend({   setupcontroller: function(controller, data) {     var socket = io.connect(),         self = this;     socket.on('apartment/new', function(apartment) {       var apt = app.apartment.createrecord(apartment);       self.controllerfor('apartments').pushobject(apt);     });   } }); 

this create new model class, pushes object controller, , creates new li values not render.

<ul class="list-view"> {{#each apartment in controller}}     <li>       {{#linkto 'apartment' apartment }}         <span class="date">{{date apartment.date}}</span>         {{apartment.title}}       {{/linkto}}     </li> {{/each}} </ul> 

does have run loop? how force values render? or there better approach this?

there's simple solution i'm using in of apps. can either have general purpose callback socket , accept kind of data

callback: function(message) {   // better `eval`   var type = ember.get(ember.lookup, message.type);   store.load(type, message.data); } 

or here tailored use case

socket.on('apartment/new', function(apartment) {   store.load(app.apartment, apartment); }); 

using store.load load record data directly identity map. there's loadmany loading multiple records.


Comments

Popular posts from this blog

c - How to retrieve a variable from the Apache configuration inside the module? -

c# - Constructor arguments cannot be passed for interface mocks -

python - malformed header from script index.py Bad header -