flow-runtime-mobx
v0.17.0
Published
Adds mobx support to flow-runtime.
Downloads
85
Readme
flow-runtime-mobx
Adds mobx support to flow-runtime.
Why?
Because mobx observables don't pass standard checks like Array.isArray(observableArray) or observableMap instanceof Map.
Installation
npm install flow-runtime-mobxor
yarn add flow-runtime-mobxUsage
Before you use any observable objects you must register the types:
import t from 'flow-runtime';
import * as mobx from 'mobx';
import flowRuntimeMobx from 'flow-runtime-mobx';
flowRuntimeMobx(t, mobx); // only need to do this once.You are now free to use ObservableArray and ObservableMap in place of their native
equivalents thoughout your app:
import {observable, ObservableMap} from 'mobx';
type Thing = {
numbers: number[];
map: Map<string, string>;
};
const thing: Thing = observable({
numbers: [1, 2, 3],
map: new ObservableMap({foo: 'bar'})
});
console.log(thing);