All Projects → mobxjs → Babel Plugin Mobx Deep Action

mobxjs / Babel Plugin Mobx Deep Action

Reduces `action` and `runInAction` boilerplates

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to Babel Plugin Mobx Deep Action

Mobx Task
Makes async function state management in MobX fun.
Stars: ✭ 218 (+98.18%)
Mutual labels:  decorators, mobx
Kneden
Transpile ES2017 async/await to vanilla ES6 Promise chains: a Babel plugin
Stars: ✭ 517 (+370%)
Mutual labels:  babel-plugin, async
Babel Plugin Transform Typescript Metadata
Babel plugin to emit decorator metadata like typescript compiler
Stars: ✭ 142 (+29.09%)
Mutual labels:  babel-plugin, decorators
React Mobx React Router4 Boilerplate
React, React-Router 4, MobX and Webpack 2-boilerplate with async routes.
Stars: ✭ 566 (+414.55%)
Mutual labels:  async, mobx
React Loadable
⏳ A higher order component for loading components with promises.
Stars: ✭ 16,238 (+14661.82%)
Mutual labels:  babel-plugin, async
Multitasking
Non-blocking Python methods using decorators
Stars: ✭ 87 (-20.91%)
Mutual labels:  async, decorators
Acme
Async ACME library written in PHP based on the Amp concurrency framework.
Stars: ✭ 102 (-7.27%)
Mutual labels:  async
Redis
Async Redis Client for PHP based on Amp.
Stars: ✭ 107 (-2.73%)
Mutual labels:  async
Fsharp.control.fusiontasks
F# Async workflow <--> .NET Task/ValueTask easy seamless interoperability library.
Stars: ✭ 101 (-8.18%)
Mutual labels:  async
Coroutines
A simple system for running nested coroutines in C#.
Stars: ✭ 100 (-9.09%)
Mutual labels:  async
Aiometer
A Python concurrency scheduling library, compatible with asyncio and trio.
Stars: ✭ 110 (+0%)
Mutual labels:  async
Backoff
Python library providing function decorators for configurable backoff and retry
Stars: ✭ 1,670 (+1418.18%)
Mutual labels:  decorators
Clean State
🐻 A pure and compact state manager, using React-hooks native implementation, automatically connect the module organization architecture. 🍋
Stars: ✭ 107 (-2.73%)
Mutual labels:  mobx
React Render Debugger
🔧 Render debugger for React
Stars: ✭ 103 (-6.36%)
Mutual labels:  decorators
Micro
Asynchronous HTTP microservices
Stars: ✭ 9,987 (+8979.09%)
Mutual labels:  async
Koa Mobx React Starter
A straightforward starter for Node javascript web projects. Using Koa, MobX and ReactJS (with universal / isomorphic server rendering)
Stars: ✭ 102 (-7.27%)
Mutual labels:  mobx
Tedis
redis client with typescript and esnext for nodejs
Stars: ✭ 109 (-0.91%)
Mutual labels:  async
Dapeng Soa
A lightweight, high performance micro-service framework
Stars: ✭ 101 (-8.18%)
Mutual labels:  async
Open.channelextensions
A set of extensions for optimizing/simplifying System.Threading.Channels usage.
Stars: ✭ 106 (-3.64%)
Mutual labels:  async
Babel Plugin Recharts
Stars: ✭ 108 (-1.82%)
Mutual labels:  babel-plugin

babel-plugin-mobx-deep-action

Build Status npm version

Allow to reduce boilerplate of writing async actions. Based on assumption, that all code created inside an action, should be handled as action too.

This plugin scans for all functions, marked as actions, and then marks all nested functions, which created inside actions as actions too.

Example

In

import { action } from "mobx";

action(function doSome() {
  fetch("/api/list").then(function(response) {
    this.items = response.dta;
  });
});

Out

"use strict";

import { action } from "mobx";

action(function doSome() {
  fetch("/api/list").then(action(function(response) {
    this.items = response.dta;
  }));
});

Caveats

Plugin support only ES6 imports. Only these imports are supported:

import {action} from "mobx";
import {action as actionAlias} from "mobx";
import * as mobx from "mobx";
import * as mobxAlias from "mobx";

For example, these cases are not supported:

const mobx = require("mobx")
const {action} = require("mobx")
import * as mobx from "my-mobx-alias"
import * as mobx from "mobx";
const {action} = mobx;
action(function() {});

Installation

$ npm install babel-plugin-mobx-deep-action

Usage

Via .babelrc (Recommended)

.babelrc

{
  "plugins": ["mobx-deep-action"]
}

Via CLI

$ babel --plugins mobx-deep-action script.js

Via Node API

require("babel-core").transform("code", {
  plugins: ["mobx-deep-action"]
});

Usage for async and generator functions.

see https://github.com/Strate/babel-plugin-mobx-async-action

Typescript decorators.

This plugin could handle decorators code, emitted from typescript, such as:

import * as tslib_1 from "tslib";
import { action } from "mobx";
export default class Class2 {
    async method() {
        const a = (other) => { };
        return a(function () { });
    }
}
tslib_1.__decorate([
    action
], Class2.prototype, "method", null);

To get this code worked, you should enable importHelpers compiler option, and get tslib package installed. Also, typescript should emit es6 modules, so, you should target your compiler to es2015+. That's all, plugin detect import from "tslib" and handle typescript decorators.

Use other package.

If you use wrapper for "mobx" package, you can pass it's name to plugin:

.babelrc

{
  "plugins": [
    ["mobx-deep-action", {
      "mobx-package": "mobx-custom"
    }]
  ]
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].