1.1.0 • Published 8 years ago

naivedux v1.1.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

naivedux

Naive redux clone

Install

npm i naivedux --save

Usage

import { Store } from 'naivedux';

const reducer = (state = {}, action) => {
  const { type, payload } = action;

  switch (type) {
    case 'UPDATE_MESSAGE': {
      return Object.assign({}, state, {
        msg: payload,
      });
    }
    default: {
      return state;
    }
  }
}

const initialState = {
  msg: 'Hello World!',
};

const store = new Store(reducer, initialState);

store.subscribe(() => {
  const { msg } = store.getState();
  document.body.innerText = msg;
});

store.dispatch({
  type: 'UPDATE_MESSAGE',
  payload: 'Goodbye World!',
});
1.1.0

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago