1.0.6 • Published 1 year ago

bf-lifecycle v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

bf-lifecycle

A class helps to trigger callback functions by history traversal

NPM JavaScript Style Guide

Examples of technology application

example1 example2

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