The document discusses data binding techniques in frontend frameworks. It explains that data binding involves instantiation, parent mutation, and child mutation. It provides examples of how different frameworks handle instantiation during app bootstrap and navigation. It also compares approaches for handling parent mutation from external sources like AJAX responses as well as internal mutations, and discusses the benefits and tradeoffs of various techniques like object observation, pub/sub, and virtual DOM approaches.
6. function
person()
{
!
!
!
}
<h1>Hello
{{name}}</h1>
!
<p>
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
7. <h1>Hello
{{name}}</h1>
!
<p>
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
( name
"Yehuda
Katz"
age
)
32
numbers
[
"718-‐877-‐1325"
] <h1>Hello
Yehuda
Katz</h1>
!
<p>
You
are
32
years
old
</p>
!
<ul>
<li>718-‐877-‐1325</li>
</ul> →
9. <h1>Hello
{{name}}</h1>
!
<p>
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
( name
"Yehuda
Katz"
age
)
32
numbers
[
"718-‐877-‐1325"
] <h1>Hello
Yehuda
Katz</h1>
!
<p>
You
are
32
years
old
</p>
!
<ul>
<li>718-‐877-‐1325</li>
</ul> →
10. [
"718-‐877-‐1325"
] ( )
<h1>Hello
Yehuda
Katz</h1>
!
<p>
You
are
32
years
old
</p>
!
<ul>
<li>718-‐877-‐1325</li>
</ul>
<h1>Hello
{{name}}</h1>
!
<p>
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
name
"Yehuda
Katz"
age
33
numbers
33
→
12. function
person()
{
!
!
!
}
<h1>Hello
{{name}}</h1>
!
<p>
{{input
value=age}}
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
13. <h1>Hello
{{name}}</h1>
!
<p>
{{input
value=age}}
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
( name
"Yehuda
Katz"
age
)
32
numbers
[
"718-‐877-‐1325"
] <h1>Hello
Yehuda
Katz</h1>
!
<p>
<input
value="32">
You
are
32
years
old
</p>
!
<ul>
<li>718-‐877-‐1325</li>
</ul> →
14. <h1>Hello
{{name}}</h1>
!
<p>
{{input
value=age}}
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
( name
"Yehuda
Katz"
age
)
32
numbers
[
"718-‐877-‐1325"
] <h1>Hello
Yehuda
Katz</h1>
!
<p>
<input
value="33">
You
are
32
years
old
</p>
!
<ul>
<li>718-‐877-‐1325</li>
</ul> →
15. <h1>Hello
{{name}}</h1>
!
<p>
{{input
value=age}}
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
( name
"Yehuda
Katz"
age
)
33
numbers
[
"718-‐877-‐1325"
] <h1>Hello
Yehuda
Katz</h1>
!
<p>
<input
value="33">
You
are
32
years
old
</p>
!
<ul>
<li>718-‐877-‐1325</li>
</ul> →
16. <h1>Hello
{{name}}</h1>
!
<p>
{{input
value=age}}
You
are
{{age}}
years
old
</p>
!
<ul>
{{#each
number
in
numbers}}
<li>{{number}}</li>
{{/each}}
</ul>
( name
"Yehuda
Katz"
age
)
33
numbers
[
"718-‐877-‐1325"
] <h1>Hello
Yehuda
Katz</h1>
!
<p>
<input
value="33">
You
are
33
years
old
</p>
!
<ul>
<li>718-‐877-‐1325</li>
</ul> →
23. Pros Cons
• Mostly transparent updates*
• Good decoupling
• No .set and works today
• Unpredictable performance
• Can obscure data flow
• *Leaky watch abstraction
25. Pros
• Explicit data flow
• No .set and works today
• Reasonably predictable
performance
Cons
• Explicit updates
• Performance edge cases
• Asterisks around server
coordination
28. Bootstrap Instantiation, Frameworks
• Backbone and React: up to you
• Angular: Automatically, via the app attribute
• Ember: Automatically, via the router
29. Navigation Instantiation, Frameworks
• Backbone: Optionally, through the router
• React: Up to you
• Angular: Optionally, via the router
• Ember: Automatically, via the router
34. Instantation Navigation Internal External
React Your choice Your choice Explicit via Callbacks
Notify parent
component, which
async triggers setState
Angular <app> Optional Router Transparent
Notify $scope, which
async updates itself,
then transparent
Ember Router Router Transparent
Notify router, which
async updates model,
then transparent
Backbone Your choice, optional
router
Your choice, optional
router "Pub Sub" "Pub Sub"
35. Instantation Navigation Internal External
React Your choice Your choice Explicit via Callbacks
Notify parent
component, which
async triggers setState
React w/
Flux Same as React Same as React Same as React
or "Pub Sub"
Same as React or
notify Flux, which
notifies listening views
("Pub Sub")
React w/
React Router React Router React Router Same as React Same as React
React w/
Both React Router React Router Same as React
or "Pub Sub"
Same as React or
notify Flux, which
notifies listening views
("Pub Sub")