Skip to content

Commit 0dfe78e

Browse files
committed
update tns readme
1 parent 29f15dd commit 0dfe78e

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

examples/type-n-search/README.md

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,31 @@ npm start
1212
it's really simple example(only 40 LOC) that reactively search github repo according to your query
1313

1414
0. create normal React Component
15+
1516
```js
16-
const TypeNsearch = (props)=>{
17-
let {search} = props.actions
18-
return <div>
19-
<input onChange={e=>search(e.target.value)}></input>
20-
<ul>
21-
{props.results&&props.results.map(item=>{
22-
return <li key={item.id}><a href={item.html_url}>{item.full_name} ({item.stargazers_count})</a></li>
23-
})}
24-
</ul>
25-
</div>
26-
}
17+
const TypeNsearch = (props)=>{
18+
let {search} = props.actions
19+
return <div>
20+
<input onChange={e=>search(e.target.value)}></input>
21+
<ul>
22+
{props.results&&props.results.map(item=>{
23+
return <li key={item.id}><a href={item.html_url}>{item.full_name} ({item.stargazers_count})</a></li>
24+
})}
25+
</ul>
26+
</div>
27+
}
2728
```
29+
2830
1. HOC(Higher Order Component)
2931
using `connect` to create a HOC over TypeNsearch
32+
3033
```js
3134
const MostTypeNSearch = connect(DATAFLOW)(TypeNsearch)
3235
```
3336
2. Compose Dataflow
3437
you see the place holder `DATAFLOW`, now we gonna fill in the real data flow how we enable the reactive action of our Component
3538
1. filter out stream only with `intent.type` of 'search'
39+
3640
```js
3741
function(intent$){
3842
let updateSink$ = intent$.filter(i=>i.type=='search')

0 commit comments

Comments
 (0)