X-client
Client part of X, in Node.js & browser.
X is a universal model layer for browser apps based on websocket (realized withdnode & shoe).
Install
in Node.js
npm install x-client
var X = ;
in browser
bower install x-client
Usage
X ; var TestModel = X; TestModel; TestModel; TestModel;
API
X properties
-
X.isReady
true
/false
if X connection is ready
X methods
-
X.config
[ { token: ... } ]
->X
pass in config, token is required
-
X.connect
[ 'server.address.with.x.service:port' ]
->X
connect to given server (should be a server with X service)
-
X.ready
[ handler() ]
->X
handler will be executed while X service ready (executed immediately if already ready)
-
X.model
[ 'name' ]
->model
define a model with name
-
X.noConflict (only in browser)
[]
->X
relinquish control of the
X
variable.
model methods
see here
Test
in Node.js
npm test
in browser
open test/browser/index.html
in browser
Build (dist file for browser)
npm run build