Sinux documentation

Sinux is a javascript library for state container. It's an implementation of the Facebook Flux architecture that use Signal over Event.

npm version npm downloads Join the chat at https://gitter.im/jbpin/sinux

Installation

Sinux is available on NPM

npm i -S sinux

Basic Usage

Sinux come with three components. Signal, Store and Command.

ES6/7

import {Store, Command} from sinux

const store = new Store({initialState: true}, 'action','action2')

new Command(store.action, (state, ...args)=> {...state, ...args} )

store.action({foo:'bar'}).then(()=> console.log(store.getState())) 
// output: {initialState: true, foo:'bar'}

ES3

Sinux use Promise. You must import a promise library. In this example will we use babel-polyfill

// polyfill is required because of generator function, only import it once in your main script
require('babel-polyfill');
var sinux = require('sinux');

var Store = sinux.Store;
var Command = sinux.Command;

var store = new Store({initialState: true}, 'action','action2');

new Command(store.action, function(state){ 
  // Array.prototype.slice.call(arguments,1)
  // ...
});

store.action({foo:'bar'}).then(function(){ 
  console.log(store.getState())
});
// output: {initialState: true, foo:'bar'}

License

MIT

results matching ""

    No results matching ""