babel-plugin-mst-async-action
v0.1.2
Published
[![npm](https://img.shields.io/npm/v/babel-plugin-mst-async-action.svg)](https://www.npmjs.com/package/babel-plugin-mst-async-action) [![travis-ci](https://travis-ci.com/newraina/babel-plugin-mst-async-action.svg?branch=master)](https://travis-ci.com/newr
Downloads
6
Maintainers
Readme
babel-plugin-mst-async-action
Converts mobx-state-tree async actions to flows
TypeScript Transformer Plugin Version
Example
In
import { types } from 'mobx-state-tree'
const store = types.model({ count: 0 }).actions(self => ({
async getCount() {
self.count = await api.getCount()
}
}))
Out
import { types, flow } from 'mobx-state-tree'
const store = types.model({ count: 0 }).actions(self => ({
getCount: flow(function*() {
self.count = yield api.getCount()
})
}))
Usage
.babelrc
{
"plugins": ["babel-plugin-mst-async-action"]
}