Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

djinn-state-history

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

djinn-state-history

Djinn-state history integration

  • 0.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-75%
Maintainers
1
Weekly downloads
 
Created
Source

Djinn-state history

Build Status Codacy Badge Codacy Badge

Djinn-state helpers for history integration

This library is just a wrapper of the history package. The HistoryService have implemented all the exported functions and its parameters of the history package (push, go, goBack, goForward, replace, block, createHref) and with two more functions (pushLocation, replaceLocation) to receive the location object instead of its original ones.

Install

npm npm i --save djinn-state djinn-state-history

yarn yarn add djinn-state djinn-state-history

Using

// djinn.js
import { Djinn } from 'djinn-state';

export const djinn = new Djinn();

// djinnServices.js
import { HistoryService } from 'djinn-state-history';
import { djinn } from './djinn';

djinn.register(HistoryService);
djinn.start();

// index.js
import { HistoryService } from 'djinn-state-history';
import { createBrowserHistory } from 'history';
import { djinn } from './djinn';
import './djinnServices';

const history = createBrowserHistory();
const service = djinn.getService(HistoryService);
service.setHistory(history);

service.push('/home');

Route blocking

Useful for authentication.

// djinn.js
import { Djinn } from 'djinn-state';

export const djinn = new Djinn();

// AuthBlocker.js
import { HistoryBlockerService } from 'djinn-state-history';

export class AuthBlocker extends HistoryBlockerService {
  canAccessRoute(location, action){
    return true; // or false
  }
}

// djinnServices.js
import { djinn } from './djinn';
import { AuthBlocker } from './AuthBlocker';

djinn.register(AuthBlocker);
djinn.start();

// index.js
import { createBrowserHistory } from 'history';
import { djinn } from './djinn';
import { AuthBlocker } from './AuthBlocker';
import './djinnServices';

const history = createBrowserHistory();
const service = djinn.getService(AuthBlocker);
service.setHistory(history);

service.push('/home');

Keywords

FAQs

Package last updated on 27 Dec 2018

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc