@history-navigation/history
v1.0.0-alpha.0
Published
Wrapper of the history module to listen for navigation events
Downloads
1
Readme
@history-navigation/history
Extension to history object to listen for user navigation on an SPA (e.g. clicking back and forward on the browser or history.goBack/history.goForward method calls);
Install
$ npm i @history-navigation/history
$ yarn add @history-navigation/history
API
Table of contents
function listenToNaviationBinder
listen to history navigation changes
| Parameter | Type | Description |
| :---------- | :------------------------------- | :--------------------------- |
| onForward
| onForward | callback on forward movement |
| onBack
| onBack | callback on back movement |
Examples
history::listenToNavigation(onForward, onBack)
listenToNavigation.bind(history)(onForward, onBack)
function listenToNaviationWrapper
| Parameter | Type | Description |
| :-------- | :----- | :-------------------- |
| history
| object | history object to use |
Returns: function(onForward, onBack) — that listens to history navigation changes
Examples
listenToNavigation(history)(onForward, onBack)
function onBack
Callback to execute when history moves backwards.
| Parameter | Type | Description |
| :-------- | :----- | :------------------------- |
| steps
| number | number of steps in history |
function onForward
Callback to execute when history moves forward.
| Parameter | Type | Description |
| :-------- | :----- | :------------------------- |
| steps
| number | number of steps in history |