3 ms·
Symmetry between code on client and server has long been the promise of server-side JS. I'm working towards a similar goal of reusing Backbone's model/collectio
by KrisJordan 16y ago
Symmetry between code on client and server has long been the promise of server-side JS. I'm working towards a similar goal of reusing Backbone's model/collection structure server-side. It does not attempt to pub/sub events to all clients with an instance of a model/collection, at least not yet.
My project simply proxies client fetch/save/destroy calls via Backbone.sync to the server. Through a RESTful URL convention and Express.js the model and collection of the client's request are recreated, any transformations applied and persisted, then sent back down the pipe. Server-side, models and collections extend their client-side bases and introduce additional functionality (i.e. per-user access control). Models and collections are not kept in memory server-side beyond the duration of a request.
- stdbrouw 16y agoYeah, I've been using a similar approach. Not as fancy as using DNode or Hendrik Joreteg's approach, but it's closer to traditional web app development and thus easier to wrap one's head around. If real-time isn't a requirement, that little bit of extra simplicity can mean a lot when testing, debugging and scaling.