0.0.4 • Published 7 years ago

@evo/swindon v0.0.4

Weekly downloads
-
License
-
Repository
-
Last release
7 years ago

SwindonJS

Promise based client web socket wrapper.

Makes it easier to chain ur async actions with ws and structured data in send method, controls connect state.

Installation

npm install --save -E @evo/swindon

Usage

Initializing Swindon

    import Swindon from 'swindon';
    
    const connectionUrl = 'ws://holocost:8080';
    const callBack = (requestMeta, data) => { /* ur code */ };
    
    const oSwindon = new Swindon(connectionUrl,{
        result: callBack,
        error: callBack,
        hello: callBack,
        message: callBack,
        lattice: callBack,
    }, { debug: true, serverTimout: 1000 });

Next we can make some actions right after connection is done

    oSwindon.connect()
        .then((data) => {
            makeStuff(data);
            // etc...
        })
        .catch((e) => { throw Error(e) });;

Sending data, and make something after

    oSwindon.send('method', [1,2,3], { msg: 'hi there'} )
        .then(({ requestMeta, data }) => {
            makeStuff(requestMeta, data);
            // etc...
        })
        .catch((e) => { throw Error(e) });
0.0.4

7 years ago

0.0.3

7 years ago

0.0.2

7 years ago

0.0.1

7 years ago