0.1.2 • Published 3 years ago

babel-plugin-mst-async-action v0.1.2

Weekly downloads
3
License
MIT
Repository
github
Last release
3 years ago

babel-plugin-mst-async-action

npm travis-ci

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