@geut/mst-drama
v0.0.3
Published
A set of functions to work with the actions of mobx-state-tree
Downloads
3
Readme
mst-drama
an event or situation, especially an unexpected one, in which there is worry or excitement and usually a lot of action
Contents
Introduction
Drama is a set of functions that help you to work with mobx-state-tree and their actions.
At the moment there are only 2 functions:
connectReduxDevtools(remotedev: object, store: object, options: { trackYield: false })
connectReduxDevtools works similar to the original connect from MST but also tracks each yield
in your async actions so
you can see in the redux devtool how the state mutates in each step.
...
import { connectReduxDevtools } from '@geut/mst-drama';
...
connectReduxDevtools(require('remotedev'), store);
flowMap(actions: object)
flowMap iterates over an object of actions and converts each generator function found in a flow async action.
...
import { flowMap } from '@geut/mst-drama';
const Todo = types.model({
title: types.string
})
.actions(self => flowMap({
setTitle(newTitle) {
self.title = newTitle
},
*asyncSetTitle(newTitle) {
yield delay(2000);
self.title = newTitle;
}
}))
Installation
- NPM:
npm install @geut/mst-drama
- Yarn:
yarn add @geut/mst-drama