forked from wsourdin/ember-parachute
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.d.ts
42 lines (37 loc) · 1.07 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
declare module 'ember-parachute' {
interface QueryParamOption<T> {
as?: string;
defaultValue?: T;
refresh?: boolean;
replace?: boolean;
scope?: 'controller';
serialize?(value: T): string;
deserialize?(value: string): T;
}
type QueryParamOptions<T> = { [K in keyof T]: QueryParamOption<T[K]> };
type QueryParamsState<T> = {
[K in keyof T]: {
value: T[K];
default: T[K];
changed: boolean;
}
};
export interface ParachuteEvent<T> {
changes: T;
changed: T;
queryParams: T;
routeName: string;
shouldRefresh: boolean;
}
export class QueryParamMixin<T> {
queryParamsState: QueryParamsState<T>;
setup(queryParamsChangedEvent: ParachuteEvent<T>): void;
queryParamsDidChange(queryParamsChangedEvent: ParachuteEvent<T>): void;
reset(queryParamsChangedEvent: ParachuteEvent<T>, isExiting: boolean): void;
resetQueryParams(params?: string[]): void;
}
export default class QueryParams<T> {
constructor(...params: Array<QueryParamOptions<T>>);
Mixin: QueryParamMixin<T> & T;
}
}