bf-lifecycle
v1.0.6
Published
A class helps to trigger callback functions by history traversal
Downloads
2
Maintainers
Readme
bf-lifecycle
A class helps to trigger callback functions by history traversal
Examples of technology application
Install
npm install --save bf-lifecycle
Usage
import BackForwardLifecycle from 'bf-lifecycle';
const bfLifecycle = new BackForwardLifecycle({
callback: () => {
// callback function after restoring from the cases - bfcache or session storage
},
storeState: () => {
// hook to store
},
restoreState: () => {
let data;
// hook to restore
return data;
},
options: {
hasDependency: true, // strict checker: did session.getItem go well?
withClearScrollWillNotStoreBfCache: true, // clear scroll: includes reloading page
},
});
bfLifecycle.mount();
Demo
Here is the demo of bf-lifecycle
<a href="ansrlm.github.io/bf-lifecycle-demo" />
Upcoming
Soon be added time-expire function on bf-lifecycle v1.1.0
Then bf-lifecycle will support react framework as hook (expect in v2.1.0)
License
MIT © ansrlm