@arted/history

0.0.103 • Public • Published

history

history is a JavaScript library that lets you easily manage session history anywhere JavaScript runs.

Installation

Using npm:

$ npm install --save history

Then with a module bundler like webpack, use as you would anything else:

// using ES6 modules
import createHistory from '@arted/history';

// using CommonJS modules
var createHistory = require('@arted/history');

Usage

Basic usage looks like this:

import createHistory from '@arted/history';

const history = createHistory();

// Get the current state.
const state = history.state;

// Listen for changes to the current location.
const unsubscribe = history.subscribe((state) => {

    // state is an object as histories
    console.log(state)
});

// Use push, replace, and go to navigate around.
history.go('/home', { method: 'REPLACE' });

// To stop listening, call the function returned from listen().
unsubscribe();

Navigation

history objects may be used programmatically change the current location using the following methods:

  • history.go(path, [state])
  • history.replace(path, [state])
  • history.goBack(path | step, [state])
  • history.block(callback)
  • history.subscribe(callback)
  • history.resolve(path)
  • history.match(path)
  • history.destroy()

Readme

Keywords

Package Sidebar

Install

npm i @arted/history

Weekly Downloads

3

Version

0.0.103

License

MIT

Unpacked Size

26.6 kB

Total Files

14

Last publish

Collaborators

  • edonet