Socket
Socket
Sign inDemoInstall

occamsrazor-history-browser

Package Overview
Dependencies
4
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    occamsrazor-history-browser

it bridges the browser history API with occamsrazor events


Version published
Weekly downloads
1
Maintainers
1
Install size
4.24 kB
Created
Weekly downloads
 

Readme

Source

occamsrazor-history-browser

This function provides a bridge between the history API and the event bus created using occamsrazor It exposes a convenient "changestate" event that fires when pushstate/replacestate are called or popstate event is triggered. See the history API

var or = require('occamsrazor');
var registerHistoryAPI = require('occamsrazor-history-browser');

var events = or();
registerHistoryAPI(events);

events.on('changestate', function (evt, newState) {
  // either pushstate was triggered on "events"
  // or popstate fired on "window". For example the user clicked back or forward
});

events.trigger('pushstate', { state: { ... }, title: 'newTitle', url: 'new.html' });

Syntax: registerHistoryAPI(events, window);

  • events: an occamsrazor instance
  • window (optional): the global object, it defaults to "window"

You can interact with the history API using 2 events: pushstate and replacestate. They takes as second argument an object with state, title, url: the arguments are then passed to history.pushstate or history.replacestate.

These events trigger 'changestate' that is called with the new state. changestate is also called by the browser when popstate is triggered (clicking the back button for example).

Keywords

FAQs

Last updated on 19 Dec 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc