Skip to content

Commit 01c88d0

Browse files
committed
update tuts
1 parent dffbdb5 commit 01c88d0

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

docs/src/main/tut/React-Most-函数式最佳实践.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ case union-type 是 pattern matching, 不是 switch case
4242

4343
``` javascript
4444
import Intent from 'intent'
45-
const counterable = connect(intent$ => {
45+
const counterable = x(intent$ => {
4646
return {
47-
sink$: intent$.map(Intent.case({
47+
update$: intent$.map(Intent.case({
4848
Inc: () => state => ({count: state.count + 1}),
4949
Dec: () => state => ({count: state.count - 1}),
5050
_: () => state => state
@@ -73,9 +73,9 @@ export default Type({
7373

7474
``` javascript
7575
import Intent from 'intent'
76-
const counterable = connect(intent$ => {
76+
const counterable = x(intent$ => {
7777
return {
78-
sink$: intent$.map(Intent.case({
78+
update$: intent$.map(Intent.case({
7979
Inc: (value) => state => ({count: state.count + value}),
8080
Dec: (value) => state => ({count: state.count - value}),
8181
_: () => state => state
@@ -133,10 +133,10 @@ lens 是 composable, immutable, functional 的更新,观察数据结构的方
133133
134134
``` javascript
135135
import {lens, over, inc, dec, identity} from 'ramda'
136-
const counterable = connect(intent$ => {
136+
const counterable = x(intent$ => {
137137
let lensCount = lens(prop('count'))
138138
return {
139-
sink$: intent$.map(Intent.case({
139+
update$: intent$.map(Intent.case({
140140
Inc: () => over(lensCount, inc)
141141
Dec: () => over(lensCount, dec),
142142
_: () => identity
@@ -153,10 +153,10 @@ flatMap
153153
``` javascript
154154
import when from 'when'
155155
import {just, from, lens, over, set, inc, dec, identity, compose} from 'ramda'
156-
const counterable = connect(intent$ => {
156+
const counterable = x(intent$ => {
157157
let lensCount = lens(prop('count'))
158158
return {
159-
sink$: intent$.map(Intent.case({
159+
update$: intent$.map(Intent.case({
160160
Inc: () => over(lensCount, inc)
161161
Dec: () => over(lensCount, dec),
162162
_: () => identity
@@ -186,10 +186,10 @@ export default Type({
186186
比如还可以创建一个wrapper,可以翻倍、减半
187187
188188
``` javascript
189-
const doublable = connect(intent$ => {
189+
const doublable = x(intent$ => {
190190
let lensCount = lens(prop('count'))
191191
return {
192-
sink$: intent$.map(Intent.case({
192+
update$: intent$.map(Intent.case({
193193
Double: () => over(lensCount, x=>x*2)
194194
Half: () => over(lensCount, x=>X/2),
195195
_: () => identity,
@@ -228,13 +228,13 @@ const CounterView = props => (
228228
搞基
229229
====
230230
231-
掌握了 lens,union-type, flatmap, compose 的概念之后,如果还不够爽,可以用一些更搞基的pattern来让代码的 ~~逼格~~ 扩展性更高一些。比如
231+
掌握了 lens,union-type, flatmap, compose 的概念之后,如果还不够爽,可以用一些更搞基的pattern来让代码的 ~~逼格~~ 扩展性更高一些。比如:
232232
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)
234234
-------------------------------------------------------------
235+
Fantasy land 标准的 Functor, Monoid, Applicative
235236
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+
-------------------------------------------------------------
239239
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

Comments
 (0)