3 ms·
I wanted to cross post this here as I already posted it in the comments. ----- I am glad you wrote about this, but I feel you are missing the real 'magic' tha
by chapel 16y ago
I wanted to cross post this here as I already posted it in the comments.
-----
I am glad you wrote about this, but I feel you are missing the real 'magic' that can be done with node.js and Backbone, or any client code you choose. Socket.io is great, fantastic even, and I think it is something that really shows the power of node.js; there is something built on top of socket.io that is even more wonderful, and it is called dnode[0]. It is really simple to use, but has a lot of potential for server process to server process and server to client communication. It is in effect RPC, and I really can't do it justice.
For the example you give up here, you could easily overwrite the Backbone.sync function and have it instead send the appropriate objects you need to fetch models on the server, while having the server call back to the client with said models. Not only that but you could easily remotely invoke the model changed functions in Backbone directly from the server. There is so much more you can do, but I lack the knowledge at this point to put it in play just yet.
[0]: https://github.com/substack/dnode https://github.com/substack/dnode & http://substack.net/posts/85e1bd/DNode-Asynchronous-Remote-Method-Invocation-for-Node-js-and-the-Browser http://substack.net/posts/85e1bd/DNode-Asynchronous-Remote-M...
- moe 16y agoOhhh this is beautiful. I'm glad to see someone is finally taking node to a direction that could really unleash its potential, rather than re-implementing a rails-like framework in javascript for the nth time. Granted this is only the first nugget, but the optimist in me wants to see this approach evolve into a framework that truly spans server and client, instead of covering only half of the story.
- tlrobinson 16y agoHow's this different than JSON-RPC, for example?
- substack 16y agoYou can pass functions around in your JSON.
- tlrobinson 16y agoThat's pretty cool. Like an asynchronous functional version of Cocoa's Distributed Objects. Are there ever problems with one side referencing objects that no longer exist on the other side? I've run into these kinds of problems due to the lack of weak references in JavaScript. Hopefully a future version of JavaScript [1][2] will fix that. [1] http://wiki.ecmascript.org/doku.php?id=strawman:weak_references http://wiki.ecmascript.org/doku.php?id=strawman:weak_referen... [2] http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps http://wiki.ecmascript.org/doku.php?id=harmony:weak_maps
- substack 16y agoReferencing objects isn't a problem since dnode doesn't do replication, it just makes copies, but referencing functions when the client disconnects can occasionally be bothersome. You do get a hook when the client disconnects: conn.on('end', fn) so that helps. At browserling.com all of our backend and frontend spanning lots of processes over several servers is tied together with dnode, and we haven't had any big problems tracking references that I can think of.