readme.md

Capsule

Capsule is an experimental web framework by @HenrikJoreteg for Node.js that uses Socket.io and Backbone.js to synchronize model state by sharing model code between the client and the server.

$ npm install capsule

MIT Licensed.

Introduction !important

Capsule presents and experimental approach to building real-time web apps that re-uses the exact same models on the server as what you serve in a script tag in the html of your app. I've used this approach for a couple of apps, one of which our team uses everyday.

It's essentially a set of convenience methods and additions to @jashkenas's excellent Backbone.js lib. In it's current state Capsule is a bit indulgent in that it makes quite a few assumptions about your app and could certainly stand to be more generic.

Core assumptions are as follows:

All synced state is stored in a root model which is kept in memory on the server (yes, this is inefficient in some ways, but completely badass in others. Please don't tell me it won't scale we're also working on tying this into @fritzy's awesome upcoming thoonk.js redis lib that will use redis for clustering/scaling).

Several of the methods in Capsule.View assume that you're also using ICanHaz.js and Mustache for your clientside templating.

How to use it

The annotated source serves as temporary API documentation of what the code is capable of. You should read it as well, before you attempt to use this:

Comments

Roadmap

Scaling questions: One big limitation of this approach in its current state is scaling. This library will be converted to use Thoonk.js to leverage Redis's clustering and pub/sub capabilities as a back end.

Better handling of offline support/flaky connections: Potentially one could build a changes queue of events if the connection is lost and then send those on reconnect.

Better/easier way to handle security instead of having to validate each message outside of the model structure on the server.

Full sample app (I've built stuff with this, but not opensourceable apps)