summaryrefslogtreecommitdiffstats
path: root/docs/api/navigation.md
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-10-03 00:59:26 +0200
committerSamy Pesse <samypesse@gmail.com>2016-10-03 00:59:26 +0200
commit3ae72bb47c146212d40fc74d857880fa0616ae57 (patch)
tree28986218bb512580272f9709fbdee01f6ede52dd /docs/api/navigation.md
parentcd2d5e5101edb466b13ada19b09ea42ef726ad96 (diff)
downloadgitbook-3ae72bb47c146212d40fc74d857880fa0616ae57.zip
gitbook-3ae72bb47c146212d40fc74d857880fa0616ae57.tar.gz
gitbook-3ae72bb47c146212d40fc74d857880fa0616ae57.tar.bz2
Sync search with querystring
Diffstat (limited to 'docs/api/navigation.md')
-rw-r--r--docs/api/navigation.md21
1 files changed, 21 insertions, 0 deletions
diff --git a/docs/api/navigation.md b/docs/api/navigation.md
new file mode 100644
index 0000000..667aa66
--- /dev/null
+++ b/docs/api/navigation.md
@@ -0,0 +1,21 @@
+# Navigation
+
+### Listen to url change
+
+Listen for changes to the current location:
+
+```js
+const onLocationChanged = (location) => {
+ console.log(location.pathname);
+ console.log(location.query);
+ console.log(location.hash);
+};
+
+module.exports = GitBook.createPlugin({
+ init: (dispatch, getState, { Navigation }) => {
+ dispatch(Navigation.listen(onLocationChanged));
+ }
+});
+```
+
+The `onLocationChanged` will be triggered for initial state.