From b5ed2f38284a64d88bdb361e2c7f90cced0c5a11 Mon Sep 17 00:00:00 2001 From: Richard Smith-Unna Date: Tue, 11 Apr 2017 15:36:27 +0300 Subject: [PATCH] Clarify `app.use()` emitter event usage (solves #470) (#472) * Explain DOMContentLoaded significance in API docs * Clarify `app.use()` emitter event usage * Typo --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 8cbefe8..0f9f306 100644 --- a/README.md +++ b/README.md @@ -259,6 +259,12 @@ Choo fires messages when certain events happen: - __`.on('render')`__: when the DOM re-renders - __`.on('pushState')`__: when the history API is triggered +The `render` event should be emitted (`emitter.emit('render')`) whenever you want the app to re-render the DOM - it won't happen on its own except when you navigate between routes. + +The `pushState` can be emitted to navigate between routes: `emitted.emit('pushState', '/some/route')`. + +Both `render` and `pushState` will only have an effect once the `DOMContentLoaded` event has been fired. + ### `app.route(routeName, handler)` Register a route on the router. Uses [nanorouter][nanorouter] under the hood. Params can be registered by prepending the routename with `:routename`, e.g. @@ -274,6 +280,7 @@ anchor links on the page is generally not recommended. New routes can be triggered through `emitter.emit('pushState', )`. By default we also catch and match all `` clicks against the router. This can be disabled by setting `opts.href` to `false` in the constructor. +Routing via `pushState` will not work until the `DOMContentLoaded` event has been fired. Querystrings (`?foo=bar`) are ignored when matching routes. They should be extracted from the `window.location` object on render events, from either a