https://github.com/alhimik45/rematch-saga
[Obsolete]
https://github.com/alhimik45/rematch-saga
Last synced: about 2 months ago
JSON representation
[Obsolete]
- Host: GitHub
- URL: https://github.com/alhimik45/rematch-saga
- Owner: alhimik45
- License: mit
- Created: 2018-10-25T16:36:37.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-12-15T11:51:33.000Z (over 6 years ago)
- Last Synced: 2024-02-28T22:23:31.352Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 192 KB
- Stars: 6
- Watchers: 3
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# THIS PACKAGE WORKS ONLY FOR VERY SIMPLE CASES
Reasons for incomplete support described in [this comment](https://github.com/alhimik45/rematch-saga/issues/1#issuecomment-441762109). 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
```js
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:
```js
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.