diff --git a/README.md b/README.md index 815226f8..c8898574 100644 --- a/README.md +++ b/README.md @@ -110,3 +110,9 @@ The following values are possible for categories (the only mandatory value is qu * const: an object variable which is available as prefix in twig functions. All values in the "feature" section may use the [TwigJS language](doc/TwigJS.md) for evaluation. + +### Hooks +With the function `register_hook` you can hook into several functions. The following hooks are available: + +* `state-get`: modules can add values into the current state. Parameters: `state`: an object, which can be modified by modules. +* `state-apply`: when a state is applied to the app. Parameters: `state`: state which should be applied. diff --git a/src/state.js b/src/state.js index 0018e0ee..ccd09fee 100644 --- a/src/state.js +++ b/src/state.js @@ -20,6 +20,9 @@ function get () { state.lon = center.lng state.zoom = zoom + // other modules + call_hooks('state-get', state) + // done return state } @@ -36,6 +39,9 @@ function apply (state) { map.flyTo({ lat: state.lat, lng: state.lon }, state.zoom) } } + + // other modules + call_hooks('state-apply', state) } function stringify (state) {