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"]
}