docs: improve app.start

This commit is contained in:
Yoshua Wuyts
2016-05-22 19:44:03 +09:00
parent a974527bce
commit 3294737792
+20 -13
View File
@@ -13,12 +13,12 @@ productive package.
- [Demos](#demos) - [Demos](#demos)
- [Usage](#usage) - [Usage](#usage)
- [Concepts](#concepts) - [Concepts](#concepts)
- [Effects](#effects) - [Effects](#effects)
- [HTTP](#http) - [HTTP](#http)
- [Subscriptions](#subscriptions) - [Subscriptions](#subscriptions)
- [server sent events](#server-sent-events-sse) - [server sent events](#server-sent-events-sse)
- [keyboard](#keyboard) - [keyboard](#keyboard)
- [websockets](#websockets) - [websockets](#websockets)
- [Rendering in Node](#rendering-in-node) - [Rendering in Node](#rendering-in-node)
- [API](#api) - [API](#api)
- [FAQ](#faq) - [FAQ](#faq)
@@ -299,14 +299,21 @@ documentation. Registered views have a signature of `(params, state, send)`,
where `params` is URI partials. where `params` is URI partials.
### html = app.toString(route, state) ### html = app.toString(route, state)
Render the application to a string. Useful for rendering on the server. First Render the application to a string of HTML. Useful for rendering on the server.
argument is a path that's passed to the router. Second argument is the state First argument is a path that's passed to the router. Second argument is the
object. When calling `.toString()` instead of `.start()`, all calls to `send()` state object. When calling `.toString()` instead of `.start()`, all calls to
are disabled, and `subscriptions`, `effects` and `reducers` aren't loaded. `send()` are disabled, and `subscriptions`, `effects` and `reducers` aren't
loaded. See [rendering in Node](#rendering-in-node) for an in-depth guide.
### tree = app.start() ### tree = app.start(opts)
Start the application. Returns a DOM element that can be mounted using Start the application. Returns a tree of DOM nodes that can be mounted using
`document.body.appendChild()`. `document.body.appendChild()`. Opts can contain the following values:
- __opts.history:__ default: `true`. Enable a `subscription` to the browser
history API. e.g. updates the internal `state.location` state whenever the
browser "forward" and "backward" buttons are pressed.
- __opts.href:__ default: `true`. Handle all relative `<a
href="<location>"></a>` clicks and update internal `state.location`
accordingly.
## FAQ ## FAQ
### How does choo compare to X? ### How does choo compare to X?