Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The State of Realtime at &yet

The State of Realtime at &yet

Talk at RealtimeConf 2012.

Henrik Joreteg

October 24, 2012
Tweet

More Decks by Henrik Joreteg

Other Decks in Technology

Transcript

  1. @HenrikJoreteg + surprise guest The State of Realtime at &yet

    as it pertains to And Bang 2.0 Wednesday, October 24, 12
  2. EMAIL -> GMAIL NOTES -> EVERNOTE TWEETS -> TWITTER CODE

    -> GITHUB Wednesday, October 24, 12
  3. CRUD IN REST: Create -> POST Read -> GET Update

    -> PUT Delete -> DELETE Wednesday, October 24, 12
  4. POST /user/47?addToGroup=friends How do you link an existing user to

    an existing group? Wednesday, October 24, 12
  5. PUT /user/47 body: { addToGroup: “friends” } How do you

    link an existing user to an existing group? Wednesday, October 24, 12
  6. Or are you actually editing the group? PUT /group/friends?addUser=47 How

    do you link an existing user to an existing group? Wednesday, October 24, 12
  7. SIMPLE UNIFIED AUTHENTICATION (since that doesn’t exist we have to

    settle for OAuth 2.0) Wednesday, October 24, 12
  8. ANY TIME DATA CHANGES AN EVENT IS PUBLISHED THAT DESCRIBES

    THE CHANGES Wednesday, October 24, 12
  9. Event type: shipTask { "eventNumber": 4270, "action": {.. metadata about

    the event type ..}, "category": "team", "instance": "1", "crud": [ { "id": "338", "type": "update", "object": "task", "data": {.. changed attributes ..} }, { "id": "2320", "type": "create", "object": "chat", "data": {.. attributes of chat message ..} } ] } Wednesday, October 24, 12
  10. // full client synchronization in ~ 20 LOC api.on(‘*’, function

    (eventType, data) { if (data.crud) { data.crud.forEach(function (crudItem) { if (crudItem.type === ‘update’) { // look up our model in memory var model = app.getModel(crudItem.object, crudItem.id); // if we find it, set our data if (model) model.set(crudItem.data); } else if (crudItem.type === ‘create’) { // create it and add it } else if (crudItem.type === ‘delete’) { // find it and delete it if found } }); } }); Wednesday, October 24, 12