Support of redux-saga for https://github.com/rematch/rematch
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples/basic
.babelrc Initial code Oct 25, 2018
.gitignore
.npmignore add .npmignore Oct 25, 2018
LICENSE.md
README.md
index.js
index.test.js
package-lock.json
package.json
utils.js Initial code Oct 25, 2018

README.md

THIS PACKAGE WORKS ONLY FOR VERY SIMPLE CASES

Reasons for incomplete support described in this comment. If you have any idea how to make it work, please write me.

Rematch Saga

Redux-saga plugin for Rematch.

Install

npm install rematch-saga

Setup

import { init } from '@rematch/core'
import sagaPlugin from 'rematch-saga'

init({
  plugins: [sagaPlugin()]
})

Optionally sagaPlugin takes sagaMiddleware. If it is not passed, plugin creates its own middleware.

Using sagas

After including plugin along with async effects you can write sagas:

const count = {
    state: 0,
    reducers: {
        increment(state) {
            return state + 1
        }
    },
    effects: {
        async incrementAsync() { // usual async effect
            await asyncDelay(1000)
            this.increment()
        },
        *incrementAsyncSaga() { // full-featured saga
            yield call(delay, 1000)
            yield call(this.increment)
        }
    }
}

Sagas are called like any other effects. See examples/ for more information.