Skip to content

Commit 2f43d27

Browse files
committed
fix(core): serialize, deserialize and compareWith are now mandatory.
1 parent 0234ebf commit 2f43d27

3 files changed

Lines changed: 7 additions & 7 deletions

File tree

projects/ngqp-demo/src/app/playground/playground.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export class PlaygroundComponent {
2525
}),
2626
range: queryParamBuilder.numericParam({
2727
name: 'range',
28-
emptyOn: 5,
28+
emptyOn: 2,
2929
}),
3030
});
3131
}

projects/ngqp/core/src/lib/model.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Comparator, isOptionalFunction, wrapTryCatch } from './util';
1+
import { Comparator, isFunction, wrapTryCatch } from './util';
22
import { createEmptyOnDeserializer, createEmptyOnSerializer } from './serializers';
33

44
/** TODO Documentation */
@@ -65,15 +65,15 @@ export class QueryParamControl<T> {
6565
constructor(opts: QueryParamControlOpts<T>) {
6666
const { name, serialize, deserialize, debounceTime, emptyOn, compareWith } = opts;
6767

68-
if (!isOptionalFunction(serialize)) {
68+
if (!isFunction(serialize)) {
6969
throw new Error(`serialize must be a function, but received ${serialize}`);
7070
}
7171

72-
if (!isOptionalFunction(deserialize)) {
72+
if (!isFunction(deserialize)) {
7373
throw new Error(`deserialize must be a function, but received ${deserialize}`);
7474
}
7575

76-
if (!isOptionalFunction(compareWith)) {
76+
if (!isFunction(compareWith)) {
7777
throw new Error(`compareWith must be a function, but received ${compareWith}`);
7878
}
7979

projects/ngqp/core/src/lib/util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ export function isMissing(obj: any): obj is null | undefined {
1515
/**
1616
* TODO Documentation
1717
*/
18-
export function isOptionalFunction(obj: any): boolean {
19-
return isMissing(obj) || typeof obj === 'function';
18+
export function isFunction(obj: any): boolean {
19+
return !isMissing(obj) && typeof obj === 'function';
2020
}
2121

2222
/**

0 commit comments

Comments
 (0)