Hello guys,
I built an Ember App using EmberJS for the frontend that is backed by a beautiful Laravel RESTful API.
So good so far,
I found that on top or the current mecanisms I got, I wanted to sync data in realtime between differents users of my system using Pusher [ http://pusher.com/ ] .
I wrote down the socket logic in my ApplicationRoute
.
I have 3 channels that receives the 3 types or interactions that are possible with entities : create, update, delete.
The contract I established for the message that are sent to my Ember app goes like this :
{
model: "post" // model name
token: "4ge4g3brth" // refer to the instance that sent the action ( explained in the code)
data: {...} // the model's data
}
So the logic in my channels that I implemented is used to properly inject the data in the store. I’m posting it here because I don’t master Ember-Data so I’m sure my code could be better.
So please, take a look at the Gist below :
https://gist.github.com/pboutin/b6d4a3209c8eb56e9c9b#file-emberjs_pusher-js
Don’t hesitate to poke me if something is not clear, I commented a lot the code so it could be readable by everybody.