WIP
This commit is contained in:
parent
263948faa3
commit
f49d580d49
1 changed files with 7 additions and 7 deletions
|
@ -29,15 +29,15 @@ import type {ILogger} from "../logging/types";
|
||||||
import type {Navigation} from "./navigation/Navigation";
|
import type {Navigation} from "./navigation/Navigation";
|
||||||
import type {URLRouter} from "./navigation/URLRouter";
|
import type {URLRouter} from "./navigation/URLRouter";
|
||||||
|
|
||||||
export type Options = {
|
type Options<N extends {session: string}> = {
|
||||||
platform: Platform
|
platform: Platform
|
||||||
logger: ILogger
|
logger: ILogger
|
||||||
urlCreator: URLRouter
|
urlCreator: URLRouter<N>
|
||||||
navigation: Navigation
|
navigation: Navigation<N>
|
||||||
emitChange?: (params: any) => void
|
emitChange?: (params: any) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export class ViewModel<O extends Options = Options> extends EventEmitter<{change: never}> {
|
export class ViewModel<N extends {session: string}, O extends Options<N> = Options<N>> extends EventEmitter<{change: never}> {
|
||||||
private disposables?: Disposables;
|
private disposables?: Disposables;
|
||||||
private _isDisposed = false;
|
private _isDisposed = false;
|
||||||
private _options: Readonly<O>;
|
private _options: Readonly<O>;
|
||||||
|
@ -47,7 +47,7 @@ export class ViewModel<O extends Options = Options> extends EventEmitter<{change
|
||||||
this._options = options;
|
this._options = options;
|
||||||
}
|
}
|
||||||
|
|
||||||
childOptions<T extends Object>(explicitOptions: T): T & Options {
|
childOptions<T extends Object>(explicitOptions: T): T & Options<N> {
|
||||||
return Object.assign({}, this._options, explicitOptions);
|
return Object.assign({}, this._options, explicitOptions);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,11 +135,11 @@ export class ViewModel<O extends Options = Options> extends EventEmitter<{change
|
||||||
return this.platform.logger;
|
return this.platform.logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
get urlCreator(): URLRouter {
|
get urlCreator(): URLRouter<N> {
|
||||||
return this._options.urlCreator;
|
return this._options.urlCreator;
|
||||||
}
|
}
|
||||||
|
|
||||||
get navigation(): Navigation {
|
get navigation(): Navigation<N> {
|
||||||
return this._options.navigation;
|
return this._options.navigation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue