rematch-logic

1.0.1 • Public • Published

rematch-logic

🕶 redux-login in rematch

Instalation

npm install -g rematch-logic
or
yarn add rematch-logic

Setup

import todo from './models/todo';
import { createLogicMiddleware } from 'redux-logic';

const logicMiddleware = createLogicMiddleware([], {});

const store = init({
  models: {
    todo
  },
  plugins: [
    rematchLogicPlugin(logicMiddleware),
  ],
  redux: {
    middlewares: [logicMiddleware]
  }
});

Usage

const model = {
  name: 'todo',
  state: [],
  reducers: {
    addTodo(state, payload) {
      return state.concat([payload])
    },
    removeTodo(state, index) {
      return state.filter((i, idx) => idx !== index);
    }
  },
  logics: [
    {
      type: [
        'todo/addTodo',
        'todo/removeTodo'
      ],
      latest: true,
      process({ getState, action },  dispatch, done) {

        /*
          do some stuff
          use dispatch a la rematch style like dispatch.todo.addTodo
        */ 
       
        done();
      }
    }
  ]
}

Readme

Keywords

Package Sidebar

Install

npm i rematch-logic

Weekly Downloads

0

Version

1.0.1

License

MIT

Unpacked Size

264 kB

Total Files

6

Last publish

Collaborators

  • russiann