@@ -178,26 +178,34 @@ Event subscription is managed automatically. No props passed - no problems.
178178
179179## Data binding
180180
181- ` nestedreact ` supports data binding based on standard React ` valueLink ` .
182- It adds following helpers:
181+ ` nestedreact ` supports data binding based compatible with standard React's ` valueLink ` .
182+ Links are "live" in a sense that they always point to actual value based on current model or collection state.
183+ It doesn't break anything in React, rather extends possible use cases.
183184
184- - ` var link = model.lget ( 'attr' ) ` creates link for model attribute. That link can
185+ - ` var link = model.getLink ( 'attr' ) ` creates link for model attribute. That link can
185186 be further transformed to valueLink for boolean property:
186- - ` link.leql( x ) ` creates boolean link which is true whenever link value is equal to x.
187- - ` link.lhas( x ) ` creates boolean link which is true whenever x is contained in an array in link value.
188- - ` var link = collection.lhas( model ) ` creates link for boolean property, toggling model in collection.
187+ - ` link.equals( x ) ` creates boolean link which is true whenever link value is equal to x.
188+ - ` link.contains( x ) ` creates boolean link which is true whenever x is contained in an array in link value.
189+ Updates to enclosed array made through this property will trigger model updates.
190+ Avoid long arrays, operations has O(N^2) complexity.
191+ - ` var link = collection.getLink( model ) ` creates link for boolean property, toggling model in collection.
189192
190193All links supports following additional methods:
191- - ` link.set( x ) ` working the same as ` link.requestChanges( x ) `
192- - ` link.toggle() ` works the same as ` link.requestChanges( !link.value ) `
194+ - ` link.val( x ) ` , ` link.set( x ) ` working the same as ` link.requestChange( x ) `
195+ - ` link.val() ` , ` link.get() ` get link value
196+ - ` link.toggle() ` works the same as ` link.set( !link.get() ) `
197+
198+ Standard members ` link.requestChange( x ) ` and ` link.value ` also works.
199+ Assignments to ` link.value ` are allowed, and works in the same way as ` link.set ` .
200+
201+ Most efficient way to work with link is using ` link.val() ` function.
193202
194203Link received through component props can be linked with state member using
195204the following declaration:
196205``` javascript
197206attributes : {
198- selected : Nested .valueLink ( ' ^props.selectedLink' )
207+ selected : Nested .link ( ' ^props.selectedLink' )
199208}
200209```
201-
202210It can be accessed as a part of state, however, ` link.requestChanges ` will be call on assignment
203211instead of state modification. Its value will be updated automatically when component will receive new props.
0 commit comments