1

I have a contact resource with a linked photo.

Both, contacts/3 and photos/56 are fetch from the server at startup. I assume it is good to keep my backbone collections in memory and avoid fetching from the server all the time. I also keep my views in the DOM as much time as I can for speed purposes.

When a user wants to delete the photo/56, from all the photos he has on the server, he can do it though the photo apps, I have to eventually update contacts/3 locally in memory.

There is many solutions, however, what is the backbone traditional way to handle this scenario and have coherent linked models on the browsers ?

  • Should I avoid keeping my models and views in memory and fetch them constantly ?
  • Should I detect the impact on the related contact and request a sync on this element ?
  • Should I have a notification resource to get those sorts of updates ?

Regards.

Alain
  • 1,450
  • 3
  • 20
  • 37
  • 1
    When you say that the user can delete a photo from the photo apps are you referring you a section of the backbone app that handles photos or a separate application? – Scott Puleo May 07 '13 at 18:02
  • For now, the deletion is initiated by an app (another view) in the same browser, so I think first interpretation is a must, althought, since I tagged this question 'realtime', I will eventually need to cover your second interpretation – Alain May 07 '13 at 19:13
  • 1
    For the first case you can tell your contacts collection to listen to the remove events on your photos collection when you bootstrap your application. – Scott Puleo May 07 '13 at 19:26
  • @ScottPuleo: ok for first interpretation , I understand that the backbone apps should manage internally as much as they can based on what they know (a removed event). And for second interpretation ? – Alain May 07 '13 at 20:19
  • 1
    You have some options. Checkout these posts: http://stackoverflow.com/questions/11718301/how-to-do-polling-in-backbone-js http://stackoverflow.com/questions/6657968/how-to-use-backbone-js-with-websockets-socket-io-nowjs – Scott Puleo May 07 '13 at 20:23
  • I am not fan of polling but it is the limitation of dealing with a request driven server. Thanks. – Alain May 07 '13 at 20:29

0 Answers0