@jack-henry/web-component-router
Advanced tools
Comparing version 2.0.3 to 3.0.0
@@ -51,3 +51,3 @@ /** | ||
/** @typedef {function(!Context, function():?):?} */ | ||
/** @typedef {function(!Context, function(...?):?):?} */ | ||
let PageCallback; | ||
@@ -223,5 +223,5 @@ | ||
* @param {boolean=} push | ||
* @return {!Context} | ||
* @return {!Promise<!Context>} | ||
*/ | ||
show(path, state, dispatch, push) { | ||
async show(path, state, dispatch, push) { | ||
const ctx = new Context(path, state, this); | ||
@@ -232,3 +232,3 @@ const prev = this.prevContext; | ||
if (false !== dispatch) { | ||
this.dispatch(ctx, prev); | ||
await this.dispatch(ctx, prev); | ||
} | ||
@@ -320,33 +320,17 @@ if (false !== ctx.handled && false !== push) { | ||
*/ | ||
dispatch(ctx, prev) { | ||
let i = 0; | ||
let j = 0; | ||
const page = this; | ||
function nextExit() { | ||
let fn = page.exits[j++]; | ||
if (!fn) { | ||
return nextEnter(); | ||
async dispatch(ctx, prev) { | ||
if (prev) { | ||
// Exit callbacks | ||
for (const fn of this.exits) { | ||
await new Promise((resolve) => fn(prev, resolve)); | ||
} | ||
fn(prev, nextExit); | ||
} | ||
function nextEnter() { | ||
let fn = page.callbacks[i++]; | ||
if (ctx.path !== page.current) { | ||
// Entry callbacks | ||
for (const fn of this.callbacks) { | ||
if (ctx.path !== this.current) { | ||
ctx.handled = false; | ||
return; | ||
} | ||
if (!fn) { | ||
return unhandled.call(page, ctx); | ||
} | ||
fn(ctx, nextEnter); | ||
await new Promise((resolve) => fn(ctx, resolve)); | ||
} | ||
if (prev) { | ||
nextExit(); | ||
} else { | ||
nextEnter(); | ||
} | ||
unhandled.call(this, ctx); | ||
} | ||
@@ -353,0 +337,0 @@ |
{ | ||
"name": "@jack-henry/web-component-router", | ||
"version": "2.0.3", | ||
"version": "3.0.0", | ||
"description": "Web Components Router", | ||
@@ -36,3 +36,3 @@ "main": "router.js", | ||
"socket.io-parser": "^4.2.3", | ||
"qs":"^6.7.3", | ||
"qs": "^6.7.3", | ||
"engine.io": "^6.4.2" | ||
@@ -39,0 +39,0 @@ }, |
@@ -229,3 +229,5 @@ /** | ||
async routeChangeCallback_(routeTreeNode, context, next) { | ||
this.routeChangeStartCallbacks_.forEach((cb) => cb()); | ||
for (const cb of this.routeChangeStartCallbacks_) { | ||
cb(); | ||
} | ||
this.prevNodeId_ = this.currentNodeId_; | ||
@@ -242,3 +244,5 @@ this.currentNodeId_ = routeTreeNode.getKey(); | ||
this.nextStateWasPopped = false; | ||
this.routeChangeCompleteCallbacks_.forEach((cb) => cb(routeError)); | ||
for (const cb of this.routeChangeCompleteCallbacks_) { | ||
cb(routeError); | ||
} | ||
} | ||
@@ -245,0 +249,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
61875
9
1499