You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/BackboneViews.md
+27-11Lines changed: 27 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,6 +3,22 @@
3
3
There are many different ways you may approach the problem when dealing with existing Bakcbone UI.
4
4
All of them are supported, enabling easy and gradual transition to React.
5
5
6
+
Though `NestedReact` offers excellent convergence layer for backbone views, raw backbone models are not supported.
7
+
To use it for smooth migration of existing backbone application to React, you need to replace `backbone` with `NestedTypes`
8
+
first (it's mostly backward compatible with Backbone 1.2 API, so transition is not hard).
9
+
Which by itself will be a big step forward, because:
10
+
- It's order of magnitude faster, so your application becomes more responsive and you can handle collection which are 10 times larger than you have now. [No kidding](http://slides.com/vladbalin/performance#/).
11
+
- It implements nested models and collections handling in the right way. During `fetch`, nested objects are updated in place, so it's safe to pass them by reference.
12
+
- It can handle model references by `id` in attributes for you too, operating on a set of independently fetched collections.
13
+
- It's type-safe, providing the same contract for model attributes as in statically typed language. Thus,
14
+
attributes are guaranteed to hold values of declared types whatever you do, making it impossible to break client-server protocol.
15
+
- At the moment of writing, no other traditional model framework supports React's pure render optimization. :)
16
+
17
+
For more information about `NestedTypes`, visit
18
+
http://volicon.github.io/backbone.nestedTypes/
19
+
and
20
+
https://github.com/Volicon/backbone.nestedTypes
21
+
6
22
## Interoperation with existing Backbone Views
7
23
8
24
Key factor of success for technology transition project is to avoid naive 'upfront rewrite' strategy.
@@ -57,13 +73,13 @@ Occasionally, you may decide to refactor your existing View to React component.
57
73
58
74
Since Backbone generally use the same architectural concept as React (detect change and then render), it's an easy process.
59
75
First of all, short vocabulary:
60
-
1. View.extend({}) -> React.createClass({}). That's an obvious part.
61
-
2. View.template -> Component.render(). Yeah. In React, `render` function just *returns* markup.
62
-
3. View.render -> Component.forceUpdate(). And if you want to update component, you should call this thingy instead.
63
-
4. View.render -> Component.componentDidUpdate(), Component.componentDidMount(). If you want to attach jQuery plugin after render, you do it here.
6. View options you receive in (4) -> Component.props
66
-
7. View.model -> Component.state
76
+
1.`View.extend({})` -> `React.createClass({})`. That's an obvious part.
77
+
2.`View.template` -> `Component.render()`. Yeah. In React, `render` function just *returns* markup.
78
+
3.`View.render` -> `Component.forceUpdate()`. And if you want to update component, you should call this thingy instead.
79
+
4.`View.render` -> `Component.componentDidUpdate()`, `Component.componentDidMount()`. If you want to attach jQuery plugin after render, you do it here.
0 commit comments