mirror-saga

0.1.0 • Public • Published

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()
    },
  }
}

Package Sidebar

Install

npm i mirror-saga

Weekly Downloads

2

Version

0.1.0

License

ISC

Last publish

Collaborators

  • shmck