Rcf-x
Rcf-x is a react component based on Rcf, it uses a clear and simple way to manage store and action
Put your component in Rcf-x and Rcf-x allows it to get store by "this.props.*" and set store by action.
store
The store is a plain object which can only be modified by action.
var store = a: 1;
action
The action is a map, each key is the name of action that can be called by "this.props[name]", and the value is a function that will return a plain object or a promise.
const action = a: storea - 1
You can call other action in a action:
const action = a: storea - 1 action
or use promise:
const action =
You can even transform your action into another action like "middleware": http://flutejs.github.io/rcf-x/examples/example-b.html
Then, you can call the store and action:
thispropsathisprops
Install
npm install rcf-x
Example
http://flutejs.github.io/rcf-x/
{ thisprops; } { return <div> A: thispropsa <button onClick=thishandleClick> click </button> </div>; } { return <div> B: thispropsa </div>; } const action = { return a: storea - 1 } ; const store = a: 1; ReactDOM;
http://flutejs.github.io/rcf-x/examples/example-a.html
API
props
name | type | description |
---|---|---|
store | object | plain object |
action | object | the return value of action is a plain object or a promise |