Clarify source of 2nd render pass re: preloading data

While the docs do say that a second render pass for preloaded data comes
from request completion, the example code for preloading data suggests that
a promise chain returned from `oninit` has a role to play in controlling the
second render pass.

The docs should make explicit where the redraw is initiated so the reader
does not mistakingly believe that `oninit()` retuning a promise changes
anything.
This commit is contained in:
Sage Gerard 2017-10-27 15:25:34 -04:00
parent bd83b32709
commit f88da1c6da

View file

@ -588,7 +588,7 @@ m.route(document.body, "/secret", {
#### Preloading data
Typically, a component can load data upon initialization. Loading data this way renders the component twice (once upon routing, and once after the request completes).
Typically, a component can load data upon initialization. Loading data this way renders the component twice. The first render pass occurs upon routing, and the second fires after the request completes. Take care to note that `loadUsers()` returns a Promise, but any Promise returned by `oninit` is currently ignored. The second render pass comes from the [`background` option for `m.request`](request.md).
```javascript
var state = {