1.0.1 • Published 3 years ago

rematch-observable v1.0.1

Weekly downloads
15
License
-
Repository
github
Last release
3 years ago

redux-observable in rematch

if you looking for rematch@1.x, please reference to rematch-observable@0.x

Setup

npm install rematch-observable --save

Usage

see more in example

// import
import { init, RematchRootState, RematchDispatch } from '@rematch/core'

// setup plugin
const rematchObservable = createRematchObservable({ epics: { sharkEpics }, models })

export const store = init({
  models,
  plugins: [rematchObservable],
})

// types
export type Dependencies = RematchObserverDependencies<Dispatch>

// epics
import { RematchEpic, ofType } from 'rematch-observable'
import { mapTo } from 'rxjs/operators'
import { RootState, Dependencies } from 'src/store'

export const sharkEpics: RematchEpic<RootState, Dependencies> = (
  action$,
  state$,
  { dispatchers },
) => {
  return action$.pipe(
    ofType(dispatchers.dolphins.increment, dispatchers.dolphins.incrementAsync),
    mapTo(dispatchers.sharks.increment(1)),
  )
}

Author

👤 JiangWeixian

Show your support

Give a ⭐️ if this project helped you!


This README was generated with ❤️ by readme-md-generator