@@ -42,9 +42,9 @@ case union-type 是 pattern matching, 不是 switch case
42
42
43
43
``` javascript
44
44
import Intent from ' intent'
45
- const counterable = connect (intent$ => {
45
+ const counterable = x (intent$ => {
46
46
return {
47
- sink $: intent$ .map (Intent .case ({
47
+ update $: intent$ .map (Intent .case ({
48
48
Inc : () => state => ({count: state .count + 1 }),
49
49
Dec : () => state => ({count: state .count - 1 }),
50
50
_ : () => state => state
@@ -73,9 +73,9 @@ export default Type({
73
73
74
74
``` javascript
75
75
import Intent from ' intent'
76
- const counterable = connect (intent$ => {
76
+ const counterable = x (intent$ => {
77
77
return {
78
- sink $: intent$ .map (Intent .case ({
78
+ update $: intent$ .map (Intent .case ({
79
79
Inc : (value ) => state => ({count: state .count + value}),
80
80
Dec : (value ) => state => ({count: state .count - value}),
81
81
_ : () => state => state
@@ -133,10 +133,10 @@ lens 是 composable, immutable, functional 的更新,观察数据结构的方
133
133
134
134
` ` ` javascript
135
135
import {lens , over , inc , dec , identity } from ' ramda'
136
- const counterable = connect (intent$ => {
136
+ const counterable = x (intent$ => {
137
137
let lensCount = lens (prop (' count' ))
138
138
return {
139
- sink $: intent$ .map (Intent .case ({
139
+ update $: intent$ .map (Intent .case ({
140
140
Inc : () => over (lensCount , inc )
141
141
Dec : () => over (lensCount , dec ),
142
142
_ : () => identity
@@ -153,10 +153,10 @@ flatMap
153
153
` ` ` javascript
154
154
import when from ' when'
155
155
import {just , from , lens , over , set , inc , dec , identity , compose } from ' ramda'
156
- const counterable = connect (intent$ => {
156
+ const counterable = x (intent$ => {
157
157
let lensCount = lens (prop (' count' ))
158
158
return {
159
- sink $: intent$ .map (Intent .case ({
159
+ update $: intent$ .map (Intent .case ({
160
160
Inc : () => over (lensCount , inc )
161
161
Dec : () => over (lensCount , dec ),
162
162
_ : () => identity
@@ -186,10 +186,10 @@ export default Type({
186
186
比如还可以创建一个wrapper,可以翻倍、减半
187
187
188
188
` ` ` javascript
189
- const doublable = connect (intent$ => {
189
+ const doublable = x (intent$ => {
190
190
let lensCount = lens (prop (' count' ))
191
191
return {
192
- sink $: intent$ .map (Intent .case ({
192
+ update $: intent$ .map (Intent .case ({
193
193
Double : () => over (lensCount , x => x * 2 )
194
194
Half : () => over (lensCount , x => X / 2 ),
195
195
_ : () => identity ,
@@ -228,13 +228,13 @@ const CounterView = props => (
228
228
搞基
229
229
====
230
230
231
- 掌握了 lens,union-type, flatmap, compose 的概念之后,如果还不够爽,可以用一些更搞基的pattern来让代码的 ~~逼格~~ 扩展性更高一些。比如
231
+ 掌握了 lens,union-type, flatmap, compose 的概念之后,如果还不够爽,可以用一些更搞基的pattern来让代码的 ~~逼格~~ 扩展性更高一些。比如:
232
232
233
- [Data types à la carte ](https://github.com/jcouyang/alacarte )
233
+ [FantasyX ](https://xreact.oyanglul.us/%E8%8C%83%E7%89%B9%E8%A5%BF.html )
234
234
-------------------------------------------------------------
235
+ Fantasy land 标准的 Functor, Monoid, Applicative
235
236
236
- 简单的说还是interpreter pattern,但不是用 free monad, 是更简单的combinator,瞬间就能去掉pattern match 和action定义的表达式扩展问题
237
-
238
- [读我](https://github.com/jcouyang/alacarte/wiki/读我)
237
+ [Data types à la carte](https://github.com/jcouyang/alacarte)
238
+ -------------------------------------------------------------
239
239
240
- 代码看 [这里 ](https://github.com/reactive-react/react-most/blob/master/examples/ alacarte/src/app.jsx )
240
+ 简单的说还是interpreter pattern,但不是用 free monad, 是更简单的combinator,瞬间就能去掉pattern match 和action定义的表达式扩展问题, [比如 ](https://github.com/jcouyang/ alacarte/wiki/读我 )
0 commit comments