/bf-lifecycle

A class helps to trigger callback functions by history traversal

Primary LanguageHTMLMIT LicenseMIT

bf-lifecycle

A class helps to trigger callback functions by history traversal

NPM JavaScript Style Guide

Applied examples

example1 example2

Install

npm install --save bf-lifecycle

Usage

import BackForwardLifecycle from 'bf-lifecycle';

let data;

const bfLifecycle = new BackForwardLifecycle({
	callback: () => {
		data = 'bfcache';
	},
	storeState: () => {
		sessionStorage.setItem('data', 'nobfcache');
	},
	restoreState: () => sessionStorage.getItem('data'),
	options: {
		hasDependency: true,
		withClearScrollWillNotStoreBfCache: true,
	},
});

bfLifecycle.mount();

data = bfLifecycle.triggerRestoreState();

Documentation

See here

<a href="ansrlm.github.io/bf-lifecycle">BF-LIFECYCLE</a>

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