Skip to content

Commit 3345bf0

Browse files
author
Vlad Balin
committed
Update readme.md
1 parent 1f14ff1 commit 3345bf0

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

examples/todomvc/readme.md

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,32 @@ By comparing object's versions. For _immutable_ data, reference to the data itse
6161

6262
Every NestedTypes model and collection has `_changeToken` property, which contains empty object `{}` reassigned every time object is updated (and {} !== {}, they are separate objects allocated on heap). Inside of `shouldComponentUpdate`, we compare these version tokens for every model and collection listed in `props` with tokens used at last render. Thus, we're able to efficiently check whenever model or collection was changed since the last render.
6363

64-
It's works faster than any generic PureRenderMixin because we dynamically compile `shouldComponentUpdate` functions with _loops unrolled_, taking props list from component's `propTypes` (loops through hashes are very expensive, as well as `Object.keys` call).
64+
It works faster than any generic PureRenderMixin because we dynamically compile `shouldComponentUpdate` functions with _loops unrolled_, taking props list from component's `propTypes` (loops through hashes are very expensive, as well as `Object.keys` call).
6565

6666
Why it's better than just deal with immutable data? Because we can have circular references, and premanent references to objects in data layer with no problems. Thus, you may safely pass nested models and collection around. As you most likely used to.
6767

68-
### But how unidirectional data flow can work?
68+
### How unidirectional data flow can work?
6969

7070
Because our models and collections can be nested, and parents detects nested changes. So, when you put something complex to the top-level component state, the state (which itself is the model in our case) will notice any changes happend deep inside, and triggers UI update.
7171

7272
There's another example illustrating that, which is a bit simpler - [flux-comparison](https://github.com/Volicon/NestedReact/tree/master/examples/flux-comparison).
7373

74+
### What are that `props` and `state` in component definitions?
75+
76+
It's type specs. In its simplest form, it describe object's shape with pairs `name : Constructor`, or `name : <primitive value>`. Like this:
77+
78+
```javascript
79+
state : {
80+
s1 : String,
81+
s2 : 'asasa', // same as String.value( 'asasa' )
82+
m : Model
83+
}
84+
```
85+
86+
`props` spec is being compiled to `propTypes`, while `state` spec is used to create [NestedTypes model](http://volicon.github.io/NestedTypes/#nested.model) which will serve instead of standard `this.state`.
87+
88+
Refer to [NestedTypes API Reference](http://volicon.github.io/NestedTypes/#attribute-types) for complete type annotation syntax.
89+
7490
### What does `editing : ToDo.from( '^props.todos' )` from `todolist.jsx` mean?
7591

7692
This is NestedTypes type annotation, which literally means "`editing` is the model of `ToDo` type which is taken from

0 commit comments

Comments
 (0)