@evo/swindon

0.0.4 • Public • Published

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) });

Readme

Keywords

Package Sidebar

Install

npm i @evo/swindon

Weekly Downloads

0

Version

0.0.4

License

none

Last publish

Collaborators

  • stoyanovk
  • lequan
  • zemlanin
  • alexander
  • seedofjoy
  • 041616
  • docccdev
  • orhideous
  • tailhook
  • hunson.abadeer
  • mark_tven
  • amostovenko
  • sadkovoy
  • himiranov
  • evo-kazymyrov