mirror-saga
v0.1.0
Published
Plugin to enable redux saga effects in Mirror.js
Downloads
6
Readme
Mirror Saga
Adds Redux Sagas to Mirror.js.
Setup
import mirrorSaga from 'mirror-saga'
mirror.defaults(mirrorSaga())
// OR optionally pass in mirror default options
// mirror.defaults(mirrorSaga(options))
Use
Add model effects as generators (*function
) and they will be treated as sagas by middleware.
mirror.model({
name: 'app',
// ...
effects: {
*runASaga(payload) {
yield delay(1000)
yield actions.app.doSomething(payload)
},
}
})
Effects that are not generators will run normally.
export default {
name: 'app',
effects: {
// runs as async function
async incrementAsync() {
await asyncDelay(1000)
actions.app.increment()
},
// runs as saga
*incrementAsyncSaga() {
yield delay(1000)
yield actions.app.increment()
},
}
}