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

@blumjs/router

Package Overview
Dependencies
Maintainers
1
Versions
64
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@blumjs/router - npm Package Compare versions

Comparing version 7.2.0 to 7.2.1

2

package.json
{
"name": "@blumjs/router",
"version": "7.2.0",
"version": "7.2.1",
"description": "",

@@ -5,0 +5,0 @@ "exports": {

@@ -5,3 +5,3 @@ <div align="center">

# Not stable!
# Not tested! Will arround March 15.

@@ -36,3 +36,9 @@ # Description

```
import { useInitRouter, createDisableBackBrowserRouteMiddleware, createRouteMiddleware, historyPush } from '@blumjs/router';
import {
useInitRouter,
createCatchBackBrowserRouteMiddleware,
createDisableBackBrowserRouteMiddleware,
createRouteMiddleware,
blumRouter
} from '@blumjs/router';

@@ -46,4 +52,7 @@ const App = () => {

},
//first arg is the name of route; second callback, that fired when pushed back in browser
//first arg is the name of route; second callback, that fired when pushed back in browser
createCatchBackBrowserRouteMiddleware('Alert', (storeRoutes, prevRoutes) => back());
//the same as createCatchBackBrowserRouteMiddleware, but make auto historyPush storeRoutes
createDisableBackBrowserRouteMiddleware('Loading', (storeRoutes, prevRoutes) => console.log('loading, please wait...')),
//custom middleware
createRouteMiddleware((storeRoutes, prevRoutes) => {

@@ -54,3 +63,3 @@ if(navigator.onLine){

}
historyPush({view: 'ConnectionError', panel: 'Offline', modal: null, popout: null});
blumRouter.historyPush({view: 'ConnectionError', panel: 'Offline', modal: null, popout: null});
return false;

@@ -83,10 +92,5 @@ })

```
import { setRoutes, setActiveView, setActivePanel, setActiveModal, setActivePopout } from '@blumjs/router';
import { setActiveViewPanel, setActivePanel, setActiveModal, setActivePopout } from '@blumjs/router';
//setRoutes accept partial routes
setRoutes({view: 'Main', panel: 'Home'});
setRoutes({modal: 'Onboarding'});
setRoutes({panel: 'Game', popout: 'Loading'});
setActiveView('Main');
setActiveViewPanel({view: 'Main', panel: 'Home'});
setActivePanel('Home');

@@ -102,3 +106,21 @@ setActiveModal('Notifications');

//if you want to, that state changed only before middlewares:
back({
isDispatchChangeStateEventBeforeMiddleware: true,
isDispatchChangeStateEventAfterMiddleware: false
});
//back is async function and you can't await it. So use options beforeBackHandledCallback (triggered after window.history.back and before middlewares) and afterBackHandledCallback (triggered when passed all midlewares)
back({
beforeBackHandledCallback: () => {
console.log("I triggered before middlewares")
},
afterBackHandledCallback: () => {
console.log("I triggered after middlewares")
}
});
//default: isDispatchChangeStateEventBeforeMiddleware = false, isDispatchChangeStateEventAfterMiddleware = true, and callbacks are null
back();
```

@@ -105,0 +127,0 @@

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