naivedux

1.1.0 • Public • Published

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!',
});

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i naivedux

    Weekly Downloads

    0

    Version

    1.1.0

    License

    MIT

    Last publish

    Collaborators

    • joblake07