1- import { Observable , Subject } from 'rxjs' ;
21import { isOptionalFunction , wrapTryCatch } from './util' ;
32
3+ /** TODO Documentation */
4+ export type ParamSerializer < T > = ( model : T | null ) => string | null ;
5+
6+ /** TODO Documentation */
7+ export type ParamDeserializer < T > = ( value : string | null ) => T | null ;
8+
9+ /**
10+ * TODO Documentation
11+ */
12+ export interface QueryParamControlOpts < T > {
13+ name : string ;
14+ serialize ?: ParamSerializer < T > ;
15+ deserialize ?: ParamDeserializer < T > ;
16+ debounceTime ?: number ;
17+ }
18+
419/**
520 * TODO Documentation
621 */
@@ -24,25 +39,19 @@ export class QueryParamControl<T> {
2439 public name : string | null = null ;
2540
2641 /** TODO Documentation */
27- public serialize : ( model : T ) => string ;
42+ public serialize : ParamSerializer < T > ;
2843
2944 /** TODO Documentation */
30- public deserialize : ( value : string ) => T ;
45+ public deserialize : ParamDeserializer < T > ;
3146
32- // TODO Who completes this?
33- private _valueChanges$ = new Subject < T > ( ) ;
3447 /** TODO Documentation */
35- public readonly valueChanges$ = this . _valueChanges$ . asObservable ( ) ;
48+ public debounceTime : number | null = null ;
3649
3750 /** TODO Documentation */
3851 public value : T = null ;
3952
4053 constructor ( config : QueryParamControlOpts < T > ) {
41- const {
42- name = null ,
43- serialize = ( model : any ) => '' + model ,
44- deserialize = ( value : string ) => value as any ,
45- } = config ;
54+ const { name, serialize, deserialize, debounceTime } = config ;
4655
4756 if ( ! isOptionalFunction ( serialize ) ) {
4857 throw new Error ( `serialize must be a function, but received ${ serialize } ` ) ;
@@ -53,18 +62,9 @@ export class QueryParamControl<T> {
5362 }
5463
5564 this . name = name ;
56-
5765 this . serialize = wrapTryCatch ( serialize , `Error while serializing value for ${ name || 'control' } ` ) ;
5866 this . deserialize = wrapTryCatch ( deserialize , `Error while deserializing value for ${ name || 'control' } ` ) ;
67+ this . debounceTime = debounceTime ;
5968 }
6069
61- }
62-
63- /**
64- * TODO Documentation
65- */
66- export interface QueryParamControlOpts < T > {
67- name ?: string ;
68- serialize ?: ( model : T ) => string | null ;
69- deserialize ?: ( value : string | null ) => T ;
7070}
0 commit comments