summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
Diffstat (limited to 'docs')
-rw-r--r--docs/api/i18n.md4
-rw-r--r--docs/api/navigation.md21
2 files changed, 23 insertions, 2 deletions
diff --git a/docs/api/i18n.md b/docs/api/i18n.md
index 026a2d5..b58f1e8 100644
--- a/docs/api/i18n.md
+++ b/docs/api/i18n.md
@@ -8,8 +8,8 @@ The first step is to register messages for a language:
```js
module.exports = GitBook.createPlugin({
- init: (dispatch) => {
- dispatch(GitBook.registerLocale('en-US', {
+ init: (dispatch, getState, { I18n }) => {
+ dispatch(I18n.registerLocale('en-US', {
MY_PLUGIN_MESSAGE: 'Hello World'
}));
}
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.