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

svelte-guard-history-router

Package Overview
Dependencies
Maintainers
1
Versions
276
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svelte-guard-history-router

svelte guarded history router

  • 1.0.1
  • Source
  • npm
  • Socket score

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

npm Greenkeeper semantic-release styled with prettier Build Status codecov.io Coverage Status Known Vulnerabilities GitHub Issues Dependency Status devDependency Status docs downloads Commitizen friendly

svelte-guard-history-router

svelte guarded history router

usage

import { Router, route, Guard } from 'svelte-guard-history-router';

let session = undefined;

class SessionGuard extends Guard {
  async enter(transition) {
    if(!session) {
      transition.redirect('/login');
    }
  }
}

export const router = new Router(
  [
    route("*", Home),
    route("/about", About),
    route("/login", Login),
    route("/article", sessionGuard, Articles),
    route("/article/:article", sessionGuard, Article),
    route("/category", sessionGuard, Categories),
    route("/category/:category", sessionGuard, Category)
  ],
  "/base"
);

API

Table of Contents

Key

Type: Object

Properties

RouterState

Type: Object

Properties

Router

Parameters

  • routes Array<Route> (optional, default [])
  • base string url (optional, default "")

Properties

push

Leave current route and enter route for given path

Parameters

subscribe

Fired when the route (or the target component changes)

Parameters

Transition

Parameters

Properties

start

start the transition

  • find matching target route
  • leave old route
  • set params
  • set current route
  • enter new route

redirect

Halt current transition and got to another route

Parameters

continue

Continue a redirected route to its original destination

rollback

Bring back the router into the state before the transition has started

Parameters
  • e Exception

Route

Parameters

  • path string
  • component SvelteComponent target to show
  • guards Array<Guard> (optional, default [])

Properties

enter

Enter the route from a former one. Calls guard enter on all guards present in our gurad but absent in the former one

Parameters

leave

Leave the route to a new one. Calls quard leave on all our guards which are not in the new route

Parameters

route

Parameters

Guard

Enforces conditions of routes Like presents of values in the context

attach

Called when guard is attached to a route

Parameters

enter

Called while entering a route (current outlet is not yet set)

Parameters

leave

Called before leaving a route

Parameters

sequenceGuard

execute guards in a sequence

Parameters

parallelGuard

execute guards in a parallel

Parameters

install

With npm do:

npm svelte-guard-history-router

license

BSD-2-Clause

Keywords

FAQs

Package last updated on 16 Sep 2019

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