@@ -36,34 +36,32 @@ also you can refer to various of [Examples](https://github.com/reactive-react/re
3636### 1. Create a simple statless component
3737``` html
3838const CounterView = props => (
39- <div >
40- <button onClick ={props.actions.dec} >-</button >
41- <span >{props.count}</span >
42- <button onClick ={props.actions.inc} >+</button >
43- </div >
39+ <div >
40+ <button onClick ={props.actions.dec} >-</button >
41+ <span >{props.count}</span >
42+ <button onClick ={props.actions.inc} >+</button >
43+ </div >
4444)
4545```
4646### 2. Define Counter's Behaviour
47471 . a counter can have actions of ` inc ` and ` dec ` , which will send a objec ` {type: 'inc'} ` or ` {type:'dec'} ` to ` Intent Stream ` if it's been call
48482 . a counter reactivly generate state transform function when recieve intent of type ` inc ` or ` dec ` .
4949``` js
50- const counterable = connect (intent$ => {
51- return {
52- actions: {
53- inc : () => ({ type: ' inc' }),
54- dec : () => ({ type: ' dec' }),
55- },
56- sink$: intent$ .map (intent => {
57- switch (intent .type ) {
58- case ' inc' :
59- return state => ({ count: state .count + 1 });
60- case ' dec' :
61- return state => ({ count: state .count - 1 });
62- default :
63- return _ => _;
64- }
65- }),
66- }
50+ const counterable = connect ((intent$ ) => {
51+ return {
52+ sink$: intent$ .map (intent => {
53+ switch (intent .type ) {
54+ case ' inc' :
55+ return state => ({ count: state .count + 1 });
56+ case ' dec' :
57+ return state => ({ count: state .count - 1 });
58+ default :
59+ return _ => _;
60+ }
61+ }),
62+ inc : () => ({ type: ' inc' }),
63+ dec : () => ({ type: ' dec' }),
64+ }
6765})
6866```
6967### 3. connect behaviour and view
@@ -72,10 +70,10 @@ const counterable = connect(intent$ => {
7270const Counter = counterable (CounterView)
7371
7472render (
75- < Most>
76- < Counter / >
77- < / Most>
78- , document .getElementById (' app' ));
73+ < Most>
74+ < Counter / >
75+ < / Most>
76+ , document .getElementById (' app' ));
7977```
8078
8179## Features
0 commit comments