GitHub PullRequestReviewCommentEvent at 2014-03-31 19:01:03
Repository: thorax
Actor: Candid
Payload: {"comment":{"url":"https://api.github.com/repos/walmartlabs/thorax/pulls/comments/11131144","id":11131144,"diff_hunk":"@@ -1254,6 +1355,118 @@ By default this calls `Thorax.onException` when an exception is thrown but imple\n \n Immediately executed version of `bindSection`. The default implementation delegates to `bindSection`.\n \n+# Server Rendering\n+\n+Server side rendering relies can be performed in any environment that supports the `$` API as well as a few core APIs used to control the page life cycle.\n+\n+- `$serverSide` Boolean flag set to true when rendering server side content.\n+- `emit()` Called when the page should be sent back to the client.\n+- `onEmit(calback)` Registers a `callback` which will be called just prior to the emit operation.\n+\n+[Fruit Loops][fruit-loops] provides this functionality out of the box but this can be added to other environments with relative ease.\n+\n+## Restore Process\n+\n+The restore process involves walking the DOM hierarchy looking for nodes that are annotated with the `data-view-restore` attribute. When such a node is found Thorax will attempt to restore based on a variety of steps discussed in the [Restore Methods](#restore-methods) section below.\n+\n+This process is kicked off by either an explicit call to `View.restore` or by calling `LayoutView.setView` on a previously restored layout view.\n+\n+The application restore process might look something like:\n+\n+    var appEl = $('[data-view-name=\"application\"]');\n+    if (appEl.length) {\n+      // Restore the application view explicitly\n+      Application.restore(appEl);\n+    } else {\n+      $('body').append(Application.el);\n+      Application.render();\n+    }\n+\n+Followed by normal controller execution, ultimately culminating in `setView` call, which will restore the rendered child.\n+\n+## Restore Methods\n+\n+There is no definitive algorithm for restoring views, instead the following heuristics are used. In the event of a mismatch the `restore:fail` event will be emitted on the candidate view with additional debugging information regarding what portion of the heuristic failed.\n+\n+### General Rules\n+\n+If the candidate view instance has already been rendered then the previous element will be replaced with the existing view element. This case is tracked by `restore:fail` with a type field of `prev-render`.\n+\n+By default restore operations are depth first recursive. This allows for restore operations to partially rerender content for the minimal number of rerender operations.\n+\n+Any view that is explicitly marked with `data-view-restore=false` will be rerendered on the client. This shortcircuits the tree traversal and causes all children to be rerendered as well.\n+\n+### `setView` calls\n+\n+When `setView` is called an attempt will be made to restore the view to the layout view's child element if marked for restore. This assumes that the view is a named view. Should it not be a rerender will occur.\n+\n+### Helper Views\n+\n+Elements rendered via a helper view such as `view` or `collection` will automatically be restored. This is done by saving the parameters passed to the helper view on the initial render. On restore the helper view will be executed in a similar manner to the initial execution, with the distinction that the `restore` method will be called after the view has initialized.","path":"README.md","position":205,"original_position":205,"commit_id":"48a9fdc11ed054bda3f5e0d0c70e4e8122e63a12","original_commit_id":"8a9420da906206ec52a2b5164e03f6b325499874","user":{"login":"Candid","id":882970,"avatar_url":"https://avatars.githubusercontent.com/u/882970?","gravatar_id":"226eb770e7d3b451a599dc5777077bbf","url":"https://api.github.com/users/Candid","html_url":"https://github.com/Candid","followers_url":"https://api.github.com/users/Candid/followers","following_url":"https://api.github.com/users/Candid/following{/other_user}","gists_url":"https://api.github.com/users/Candid/gists{/gist_id}","starred_url":"https://api.github.com/users/Candid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Candid/subscriptions","organizations_url":"https://api.github.com/users/Candid/orgs","repos_url":"https://api.github.com/users/Candid/repos","events_url":"https://api.github.com/users/Candid/events{/privacy}","received_events_url":"https://api.github.com/users/Candid/received_events","type":"User","site_admin":false},"body":"Where are the parameters saved? How does the view know which DOM element to use as root for the subview?","created_at":"2014-03-31T19:01:03Z","updated_at":"2014-03-31T19:01:03Z","html_url":"https://github.com/walmartlabs/thorax/pull/345#discussion_r11131144","pull_request_url":"https://api.github.com/repos/walmartlabs/thorax/pulls/345","_links":{"self":{"href":"https://api.github.com/repos/walmartlabs/thorax/pulls/comments/11131144"},"html":{"href":"https://github.com/walmartlabs/thorax/pull/345#discussion_r11131144"},"pull_request":{"href":"https://api.github.com/repos/walmartlabs/thorax/pulls/345"}}}}