ajlopez / SRedux

Simple Redux-like library, written in plain JavaScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SRedux

Simple Redux-like library, in plain JavaScript

Totally inspired in Redux

Installation

Via npm on Node:

npm install sredux

In your browser: TBD

Usage

// your reducer function
function reducer(state, action) {
    return state + 1;
}

// create store with reducer and optional initial state (undefined as default value)    
var store = sredux.createStore(reducer, 0);

// subscribe to states, returning unsubscribe function
var unsubscribe = store.subscribe(function () {
    console.log('new state', store.getState());
});

// send action
store.dispatch({ type: 'ANY ACTION' });
// new state 1

// unsubscribe
unsubscribe();

Samples

TBD

Versions

  • 0.0.1 Published

Contribution

Feel free to file issues and submit pull requests — contributions are welcome.

If you submit a pull request, please be sure to add or update corresponding test cases, and ensure that npm test continues to pass.

About

Simple Redux-like library, written in plain JavaScript

License:Other


Languages

Language:JavaScript 100.0%