refactor: improve props and state typing
This commit is contained in:
@@ -4,18 +4,20 @@ import { WebApplication } from '@/ui_models/application';
|
|||||||
export type CtrlState = Partial<Record<string, any>>
|
export type CtrlState = Partial<Record<string, any>>
|
||||||
export type CtrlProps = Partial<Record<string, any>>
|
export type CtrlProps = Partial<Record<string, any>>
|
||||||
|
|
||||||
export class PureViewCtrl {
|
export class PureViewCtrl<P = CtrlProps, S = CtrlState> {
|
||||||
$timeout: ng.ITimeoutService
|
$timeout: ng.ITimeoutService
|
||||||
/** Passed through templates */
|
/** Passed through templates */
|
||||||
application!: WebApplication
|
application!: WebApplication
|
||||||
props: CtrlProps = {}
|
state: S = {} as any
|
||||||
state: CtrlState = {}
|
|
||||||
private unsubApp: any
|
private unsubApp: any
|
||||||
private unsubState: any
|
private unsubState: any
|
||||||
private stateTimeout: any
|
private stateTimeout?: ng.IPromise<void>
|
||||||
|
|
||||||
/* @ngInject */
|
/* @ngInject */
|
||||||
constructor($timeout: ng.ITimeoutService) {
|
constructor(
|
||||||
|
$timeout: ng.ITimeoutService,
|
||||||
|
public props: P = {} as any
|
||||||
|
) {
|
||||||
this.$timeout = $timeout;
|
this.$timeout = $timeout;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,8 +55,8 @@ export class PureViewCtrl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @override */
|
/** @override */
|
||||||
getInitialState() {
|
getInitialState(): S {
|
||||||
return {};
|
return {} as any;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setState(state: CtrlState) {
|
async setState(state: CtrlState) {
|
||||||
|
|||||||
Reference in New Issue
Block a user