Browse Source

State: hooks 'state-get', 'state-apply'

master
parent
commit
149d74516f
  1. 6
      README.md
  2. 6
      src/state.js

6
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.

6
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) {

Loading…
Cancel
Save