History Plus Plus
This module serves as a replacement for Chrome's native history api.
import { createHistory } from 'historypp'
const historypp = createHistory(history)
const historypp = initHistoryPlusPlus(history)
History stack or list
historypp.position //value from: 0 - 2
historypp.list //list of pages navigated: [{...},{...},{...}]
HistoryPP stores navigation list on history.list, you can go forwad and backward throw the list
with total freedom. Also you cand modify the list and the navigation won't break
methods
historypp.navigate(url[,options,state])
historypp.getActualData()
historypp.back()
historypp.forward()
historypp.navigateReplace(url[,options,state])
historypp.navigatePopOnBack(url[,options,state])
preventBackOnce(url,callback)
historypp.addEventListenr(name, callback)
historypp.removeEventListenr(name, callback)
historypp.length
historypp.url
historypp.state
historypp.state
One time back listener (preventBackOnce)
const listener = historypp.preventBackOnce(() => {
console.log("clicked back!")
})
listener.cancel()
Events
historypp.addEventListenr('locationchanged', item => {
console.log(item.position)
console.log(item.type)
console.log(item.movement)
console.log(item.state)
console.log(item.url)
})
historypp.addEventListenr('forward', item => {
console.log(item.position)
console.log(item.type)
console.log(item.movement)
console.log(item.state)
console.log(item.url)
})
historypp.addEventListenr('back', item => {
console.log(item.position)
console.log(item.type)
console.log(item.movement)
console.log(item.state)
console.log(item.url)
})
historypp.addEventListenr('hashchange', item => {
console.log(item.newhash)
console.log(item.lasthash)
})
historypp.addEventListenr('splice', item => {
console.log(item.start)
console.log(item.length)
someCopyOfHistoryList.splice(item.start, item.length)
})