Skip to content

Commit 31d0d85

Browse files
committed
update tut
1 parent c830335 commit 31d0d85

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

docs/src/main/tut/Fantasy.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,31 @@ position: 3
77

88
# XReact Fantasy
99

10-
xreact is a Functional library that can integrate FRP lib rxjs or mostjs into react. But there're still too many details you need to care while modeling UI components.
10+
xReact is a Functional library that can integrate FRP lib rxjs or mostjs into react. But there're still too many verbose you need to care while modeling UI components.
1111

1212
The implement of [Fantasy Land](https://github.com/fantasyland/fantasy-land), which will change the way you model and implement UI entirely.
1313

14+
> The idea of FantasyX is highly inspired by [flare](http://sharkdp.github.io/purescript-flare/) by purescript
15+
1416
## `lift`
1517

1618
Let's use List as example, what `lift` does is very similar to `map`
1719

1820
```js
19-
[1,2,3].map(x=>x+1) // => [2,3,4]
21+
const f = x => x + 1
22+
[1,2,3].map(f) // => [2,3,4]
2023
```
2124

25+
It simply map `f` to every items in the list. While if we do it another way around:
26+
2227
```js
23-
lift(x=>x+1)([1,2,3]) // => [2,3,4]
28+
const lf = lift(f)
29+
lf([1,2,3]) // => [2,3,4]
2430
```
2531

26-
You should notice that both lift and map transform `x => x + 1` which should only able to apply to `Number`, to a function that can apply to `Array[Number]`
32+
Now `lf` can take a list, apply `f` to each item, and return a new list. So `lf` is just a lifted version of `f`. You should notice that both lift and map transform `x => x + 1` which should only able to apply to `Number`, to a function that can apply to `Array<Number>`
2733

28-
We can now (from v2.3.0) lift a normal function to which can apply to xReact FantasyX as well.
34+
We can now (from v2.3.0) lift a normal function(takes value and return value) to a FantasyX level function(take FantasyX and return FantasyX) as well.
2935

3036
Let's take a look at a really simple example, multiply 2 numbers.
3137

@@ -37,7 +43,7 @@ function mult(a, b) {
3743
mult(1, 2)
3844
```
3945

40-
But if we need a React Component that multiply 2 numbers from 2 input box, how complicated it could be?
46+
But if we need a React Component that multiply 2 numbers from 2 input boxes, how complicated it could be?
4147

4248
Now you get simply get a free FantasyX from just any normal function, via `lift`.
4349

docs/src/main/tut/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ All code is available to you under the MIT license. The design is informed by ma
6767
- [rxjs](https://github.com/ReactiveX/rxjs)
6868
- [most](https://github.com/cujojs/most)
6969
- [React](http://facebook.github.io/react/)
70+
- [purescript-flare](https://github.com/sharkdp/purescript-flare)
7071
- [redux](https://github.com/rackt/redux)
7172
- [Om](https://github.com/omcljs/om)
7273
- [Cycle](http://cycle.js.org/)

0 commit comments

Comments
 (0)