Suggestions for websocket use in Ember Data 1.0.0 Beta 1


#1

Hi there. I am using a websocket connection with ember-data. I have updated to Ember Data 1.0.0 Beta 2 and previously I could load records by writing a custom adapter then using didFindRecord() in a socket event listener like so.

socket.events.on('someMessage',function(data){
    MyAdapter.didFindRecord(App.Store,App.MyModel,data,data.id);
}

I can still send a socket request through a routes model hook to a custom adapter in ED 1.0.0 Beta 2 but now that didFindRecord appears to be deprecated its unclear how websocket originating JSON data should be loaded into the store. I’ve tried something to the effect of

socket.events.on('someMessage',function(data){
   DS.Store.push('myModel',data);
})

But I get the error below I’m assuming because of how all find() methods return a promise in Ember 1.0.0

Assertion failed: You made a request for a myModel with id 1, but the adapter’s response did not have any data

Anyone out there have a solution for using websockets with ember 1.0.0/ember-data beta 2 ?


#2

This PR has just been merged: https://github.com/emberjs/data/pull/1309

It adds the pushPayload method that will allow you to push JSON in the same format as your usual ajax endpoint.