Skip to content
/ mst-drama Public

A set of functions to work with the actions of mobx-state-tree

Notifications You must be signed in to change notification settings

geut/mst-drama

Repository files navigation

mst-drama

an event or situation, especially an unexpected one, in which there is worry or excitement and usually a lot of action

Build Status Stability: Experimental

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);

connect-redux-devtool

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

About

A set of functions to work with the actions of mobx-state-tree

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published