0.1.0 • Published 2 years ago

@jsar/mobx-saga v0.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

MobX Saga

A bridge between Redux-Saga and MobX

$ npm install @jsar/mobx-saga

Getting Started

import { createMobXSaga } from '@jsar/mobx-saga'
import rootStore from './rootStore'

const saga = createMobXSaga({
  store: rootStore
})

saga.run(function *rootSaga() {
  ...
})

// Action Dispatcher
saga.dispatch(myAction)

commit Effect

import { commit, type Mutation } from "@jsar/mobx-saga";
import type { RootStore } from "./rootStore";

type RootStore = { value: number };

const increment: Mutation<RootStore, [number]> = (store, inc) => {
  store.value += inc;
};

function* incSaga() {
  yield commit(increment, 1);
}