Wuwei
Wuwei is a Data-Driven Reactive Framework.

Usage
$store, $action
You need $store and $action to use Wuwei.
Access $store & $action
var $store $action = ; // @params namespace: The namespace for your App.
Wuwei provide namespace to seperate different App's store space.
ActiveStore
君君,臣臣,父父,子子
Principle
-
Every store as instance of Store Class which extends from ActiveStore.
-
Stores maybe have other source stores to construct themself.
-
You can define logic in Store Class.

Example of Store Class
var ActiveStore = ; { this; }
In this case, Score has source store "counter", when counter's value changed, will trigger "onSourceUpdate" to update Score itself.
onSourceUpdate( ...storeValues )
ActiveStore provide method "onSourceUpdate", you can override it to implement how to update this store when source store changed.
Create a Store
$store; /*@params store_name: Name of this store.@params store_name: Object Class of this store. (extends from ActiveStore)*/
// Example$store;
Access a Store
// Example$storescore
ActiveStore Public Method
source( ...storeNames )
Define source stores of this store.
// Example$storefoosource'bar1' 'bar2';// or$storesource'counter';
getName()
Access the name of this store.
// Example$storescore
setValue( { key: value } )
Assign value to this store, store will check whether changed with immutable object comparison.
// Example$storescore;
getValue()
Access the value of this store.
// Example$storescore;// => {value: 100}
subscribe( callback( newValue ) )
You subscribe a store, when the store's value changed will trigger callback you assigned.
// Example$storefoo;
subscribe with ReactJS
If you use ReactJS, you can subscribe store to react component with follow example.
// Examplethisstate = stateKey: $storefoo;// orthisstate = $store
Basic Example
This is a counter app with Wuwei.
App.js
; var $store $action = ; { // Set store & stores's path $store $storesource'counter'; // set store default value $storecounter;}; { super; thisstate = $store; } { $action; } { $action; } { return <div> <h1>Counter</h1> <h2>thisstatecountervalue</h2> <h2>Score: thisstatescorevalue</h2> <button onClick=thisplus >plus</button> <button onClick=thisminus >minus</button> </div> ; }
Counter.js
var ActiveStore = ; { this; } { this; } { // this.setValue({}) use setValue to change this store value. }
Score.js
var ActiveStore = ; { this; }