boring-router
Advanced tools
Comparing version 0.5.8 to 0.5.9
@@ -25,3 +25,3 @@ export declare type HistoryChangeCallbackRemovalHandler = () => void; | ||
abstract replace(ref: string, data?: unknown): Promise<void>; | ||
abstract restore(snapshot: HistorySnapshot<TEntryId, TData>): Promise<void>; | ||
abstract restore(snapshot: HistorySnapshot<TEntryId, TData>, toEmitChange?: boolean): Promise<void>; | ||
protected emitChange(snapshot: HistorySnapshot<TEntryId, TData>): void; | ||
@@ -28,0 +28,0 @@ } |
@@ -24,3 +24,3 @@ import { AbstractHistory, HistorySnapshot } from './history'; | ||
replace(ref: string, data?: TData): Promise<void>; | ||
restore(snapshot: HistorySnapshot<number, TData>): Promise<void>; | ||
restore(snapshot: HistorySnapshot<number, TData>, toEmitChange?: boolean): Promise<void>; | ||
} |
@@ -113,4 +113,7 @@ "use strict"; | ||
} | ||
async restore(snapshot) { | ||
async restore(snapshot, toEmitChange = false) { | ||
this._snapshot = snapshot; | ||
if (toEmitChange) { | ||
this.emitChange(this._snapshot); | ||
} | ||
} | ||
@@ -117,0 +120,0 @@ } |
import { Dict, EmptyObjectPatch } from 'tslang'; | ||
import { IHistory } from './history'; | ||
import { HistorySnapshot, IHistory } from './history'; | ||
import { RouteBuilder } from './route-builder'; | ||
@@ -55,5 +55,8 @@ import { NextRouteMatch, RouteMatch, RouteMatchShared, RouteMatchSharedToParamDict } from './route-match'; | ||
export declare type RouterHistory = IHistory<unknown, RouterHistoryEntryData>; | ||
export declare type RouterHistorySnapshot = HistorySnapshot<unknown, RouterHistoryEntryData>; | ||
export declare class Router<TGroupName extends string = string> { | ||
constructor(history: RouterHistory, { segmentMatcher }?: RouterOptions); | ||
get $routing(): boolean; | ||
get $snapshot(): RouterHistorySnapshot | undefined; | ||
get $nextSnapshot(): RouterHistorySnapshot | undefined; | ||
get $current(): RouteBuilder<TGroupName>; | ||
@@ -60,0 +63,0 @@ get $next(): RouteBuilder<TGroupName>; |
@@ -214,2 +214,8 @@ "use strict"; | ||
} | ||
get $snapshot() { | ||
return this._snapshot; | ||
} | ||
get $nextSnapshot() { | ||
return this._nextSnapshot; | ||
} | ||
get $current() { | ||
@@ -216,0 +222,0 @@ return new route_builder_1.RouteBuilder(this, 'current'); |
{ | ||
"name": "boring-router", | ||
"version": "0.5.8", | ||
"version": "0.5.9", | ||
"description": "A type-safe MobX router with parallel routing support.", | ||
@@ -37,3 +37,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "8c5732eae954466cc429d6a40fadb26c05c7eca0" | ||
"gitHead": "6a982590f61786532ae3733f16bb7e4052e52146" | ||
} |
@@ -59,3 +59,6 @@ export type HistoryChangeCallbackRemovalHandler = () => void; | ||
abstract restore(snapshot: HistorySnapshot<TEntryId, TData>): Promise<void>; | ||
abstract restore( | ||
snapshot: HistorySnapshot<TEntryId, TData>, | ||
toEmitChange?: boolean, | ||
): Promise<void>; | ||
@@ -62,0 +65,0 @@ protected emitChange(snapshot: HistorySnapshot<TEntryId, TData>): void { |
@@ -155,5 +155,12 @@ import { | ||
async restore(snapshot: HistorySnapshot<number, TData>): Promise<void> { | ||
async restore( | ||
snapshot: HistorySnapshot<number, TData>, | ||
toEmitChange = false, | ||
): Promise<void> { | ||
this._snapshot = snapshot; | ||
if (toEmitChange) { | ||
this.emitChange(this._snapshot); | ||
} | ||
} | ||
} |
@@ -223,3 +223,6 @@ import hyphenate from 'hyphenate'; | ||
type RouterHistorySnapshot = HistorySnapshot<unknown, RouterHistoryEntryData>; | ||
export type RouterHistorySnapshot = HistorySnapshot< | ||
unknown, | ||
RouterHistoryEntryData | ||
>; | ||
@@ -288,2 +291,10 @@ interface InterUpdateData { | ||
get $snapshot(): RouterHistorySnapshot | undefined { | ||
return this._snapshot; | ||
} | ||
get $nextSnapshot(): RouterHistorySnapshot | undefined { | ||
return this._nextSnapshot; | ||
} | ||
get $current(): RouteBuilder<TGroupName> { | ||
@@ -290,0 +301,0 @@ return new RouteBuilder(this, 'current'); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
253080
5074