@frui.ts/screens
Advanced tools
Comparing version 0.15.0-beta.1 to 0.15.0-beta.2
import { IScreen } from "../structure/types"; | ||
import { Class, ICanNavigate, INavigationParent, RouteDefinition } from "./types"; | ||
export default class Router { | ||
private routes; | ||
private rootViewModel; | ||
private routes; | ||
constructor(rootViewModel: ICanNavigate); | ||
start(): void; | ||
start(rootViewModel: ICanNavigate): void; | ||
getPath(routeName: string, params?: any): string | false | undefined; | ||
@@ -9,0 +8,0 @@ getUrl(routeName: string, routeParams?: any, queryParams?: any): string; |
@@ -31,7 +31,7 @@ "use strict"; | ||
var Router = (function () { | ||
function Router(rootViewModel) { | ||
this.rootViewModel = rootViewModel; | ||
function Router() { | ||
this.routes = new Map(); | ||
} | ||
Router.prototype.start = function () { | ||
Router.prototype.start = function (rootViewModel) { | ||
this.rootViewModel = rootViewModel; | ||
var rootKey = this.findRootRouteKey(); | ||
@@ -38,0 +38,0 @@ if (rootKey) { |
import { ICanNavigate } from "./types"; | ||
export default class UrlNavigationAdapter { | ||
private rootViewModel; | ||
private isNavigationSuppressed; | ||
private isStarted; | ||
private lastUrl; | ||
constructor(rootViewModel: ICanNavigate); | ||
start(): Promise<void>; | ||
private rootViewModel?; | ||
start(rootViewModel: ICanNavigate): Promise<void>; | ||
stop(): void; | ||
@@ -10,0 +8,0 @@ private onScreenChanged; |
@@ -56,10 +56,8 @@ "use strict"; | ||
var UrlNavigationAdapter = (function () { | ||
function UrlNavigationAdapter(rootViewModel) { | ||
this.rootViewModel = rootViewModel; | ||
function UrlNavigationAdapter() { | ||
this.isNavigationSuppressed = false; | ||
this.isStarted = false; | ||
this.lastUrl = ""; | ||
} | ||
UrlNavigationAdapter.prototype.start = function () { | ||
this.isStarted = true; | ||
UrlNavigationAdapter.prototype.start = function (rootViewModel) { | ||
this.rootViewModel = rootViewModel; | ||
navigationConfiguration_1.default.onScreenChanged = this.onScreenChanged; | ||
@@ -70,6 +68,6 @@ window.addEventListener("hashchange", this.onUrlChanged, false); | ||
UrlNavigationAdapter.prototype.stop = function () { | ||
this.isStarted = false; | ||
this.rootViewModel = undefined; | ||
}; | ||
UrlNavigationAdapter.prototype.onScreenChanged = function (screen) { | ||
if (this.isStarted && !this.isNavigationSuppressed) { | ||
if (this.rootViewModel && !this.isNavigationSuppressed) { | ||
var path = screen.getNavigationPath(); | ||
@@ -90,3 +88,3 @@ var url = navigationPath_1.appendQueryString(navigationConfiguration_1.default.hashPrefix + path.path, path.params); | ||
hash = window.location.hash; | ||
if (!(this.isStarted && hash && hash.startsWith(navigationConfiguration_1.default.hashPrefix))) return [3, 5]; | ||
if (!(this.rootViewModel && hash && hash.startsWith(navigationConfiguration_1.default.hashPrefix))) return [3, 5]; | ||
path = query_string_1.parseUrl(hash.substr(navigationConfiguration_1.default.hashPrefix.length)); | ||
@@ -93,0 +91,0 @@ this.isNavigationSuppressed = true; |
@@ -10,3 +10,3 @@ import ConductorBase from "./conductorBase"; | ||
protected onActivate(): Promise<any[]>; | ||
protected onDeactivate(isClosing: boolean): Promise<void>; | ||
protected onDeactivate(close: boolean): Promise<void>; | ||
protected connectChild(child: TChild): void; | ||
@@ -13,0 +13,0 @@ protected findNavigationChild(name: string): Promise<TChild | undefined> | TChild | undefined; |
@@ -148,3 +148,3 @@ "use strict"; | ||
}; | ||
ConductorAllChildrenActive.prototype.onDeactivate = function (isClosing) { | ||
ConductorAllChildrenActive.prototype.onDeactivate = function (close) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
@@ -163,3 +163,3 @@ var _a, _b, child, e_2_1; | ||
if (!helpers_2.isDeactivatable(child)) return [3, 3]; | ||
return [4, child.deactivate(isClosing)]; | ||
return [4, child.deactivate(close)]; | ||
case 2: | ||
@@ -183,3 +183,3 @@ _d.sent(); | ||
case 7: | ||
if (isClosing) { | ||
if (close) { | ||
this.children.clear(); | ||
@@ -186,0 +186,0 @@ } |
@@ -24,3 +24,3 @@ import { NavigationPath } from "../navigation/navigationPath"; | ||
protected onActivate(): Promise<any> | void; | ||
protected onDeactivate(isClosing: boolean): Promise<any> | void; | ||
protected onDeactivate(close: boolean): Promise<any> | void; | ||
protected get canBeNavigationActiveScreen(): boolean; | ||
@@ -27,0 +27,0 @@ protected notifyNavigationChanged(): void; |
@@ -170,3 +170,3 @@ "use strict"; | ||
ScreenBase.prototype.onActivate = function () { }; | ||
ScreenBase.prototype.onDeactivate = function (isClosing) { }; | ||
ScreenBase.prototype.onDeactivate = function (close) { }; | ||
Object.defineProperty(ScreenBase.prototype, "canBeNavigationActiveScreen", { | ||
@@ -173,0 +173,0 @@ get: function () { |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "0.15.0-beta.1", | ||
"version": "0.15.0-beta.2", | ||
"description": "Frui.ts core classes for application structure and navigation", | ||
@@ -38,3 +38,4 @@ "keywords": [ | ||
"dependencies": { | ||
"@frui.ts/helpers": "^0.15.0-beta.1", | ||
"@frui.ts/helpers": "^0.15.0-beta.2", | ||
"mobx": "^4.15.4", | ||
"query-string": "^6.9.0", | ||
@@ -46,6 +47,3 @@ "route-parser": "^0.0.5" | ||
}, | ||
"peerDependencies": { | ||
"mobx": "^4.0.0 || ^5.0.0" | ||
}, | ||
"gitHead": "2d202d197d961a3cf539b5082fce1eaa416d1238" | ||
"gitHead": "a1950d8a2f4b4b2bfddbca22972c322b2586c33d" | ||
} |
@@ -182,4 +182,4 @@ # `@frui.ts/screens` | ||
const router = new Router(rootViewModel); | ||
router.start(); | ||
const router = new Router(); | ||
router.start(rootViewModel); | ||
@@ -203,6 +203,6 @@ ... | ||
... | ||
const urlAdapter = new UrlNavigationAdapter(rootViewModel); | ||
urlAdapter.start(); | ||
const urlAdapter = new UrlNavigationAdapter(); | ||
urlAdapter.start(rootViewModel); | ||
``` | ||
Implement `ICanNavigate` if you want to control the navigation path for children and react to changes in the navigation path. Note that the conductors described above already implement `ICanNavigate`. |
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
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
152765
1875
+ Addedmobx@^4.15.4
+ Addedmobx@4.15.7(transitive)
- Removedmobx@5.15.7(transitive)