canal-client

0.1.5 • Public • Published

Build Status

Canal-io

A data transfer libs to connect client and server seamless. Inspired from Meteor data binding use WebSocket to deliver data between client and server.

This is not a only a warp of meteor data binding functional but also lots of new. Use co to made control flow friendly, use JSON like selector(now is mongodb selector) to query data on development but not like meteor can be easily refactor to security configurable environment.

canal-client

This is the client side can run in node 4.x 5.x directly. Also can be used in a browser with some 6to5 compiler

This package is in a very early stages and still being developed, for now it's run some test only. If you have interesting with this please see it later

Usage

'use strict';
var canal = require('canal-client');
 
// fetch data with selector
canal('/path/to/data').fetch(
    {"carrier.fee": { $gt: 2 }},
    { $set: { price: 9.99 } }
    ).then();
 
// A/A
canal(function*(){
    // assume we get data from same path
    let worker = canal('/path/to/data');
    let ret = yield worker.fetch('id');
    ret = yield worker.fetch({cond: ret});
    return yield worker.remove({cond: ret});
}).then();
 
// listen
canal('/path/to/data').listen({cond: ret}, function*(done, data){
    let ret = yield Promise.resolve(data);
    done(ret);
});
 
// listen inside a generator
canal(function*(){
    let ret = yield canal('/path/to/data').fetch('id');
    ret = yield canal('/path/to/data').listen({cond: ret}, function*(done, data){
            let ret = yield Promise.resolve(data);
            done(ret);
    });
    return yield canal('/path/to/data').remove({cond: ret});
}).then();
 
// safety use
canal('/methodsName').fetch([para]).then();
canal('/methodsName').update([para]).then();

Copyright and license

Code and documentation © 2016 canal-io Released under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i canal-client

Weekly Downloads

10

Version

0.1.5

License

MIT

Last publish

Collaborators

  • tsumina