Skip to content

Commit 1f48db0

Browse files
doc(ParamType): add note about registering before using
1 parent 3aee2b7 commit 1f48db0

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/url/urlMatcherFactory.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {matcherConfig} from "./urlMatcherConfig";
77
import {Param} from "../params/param";
88
import {paramTypes} from "../params/paramTypes";
99
import {ParamType} from "../params/type";
10+
import {ParamTypeDefinition} from "../params/interface";
1011

1112
/** @hidden */
1213
function getDefaultConfig() {
@@ -92,21 +93,25 @@ export class UrlMatcherFactory {
9293
};
9394

9495
/**
95-
* Creates and registers a custom [[ParamType]] object that can be used to generate URLs with typed parameters.
96+
* Creates and registers a custom [[ParamType]] object
97+
*
98+
* A [[ParamType]] can be used to generate URLs with typed parameters.
9699
*
97100
* @param name The type name.
98101
* @param definition The type definition. See [[ParamTypeDefinition]] for information on the values accepted.
99-
* @param definitionFn A function that is injected before the app
100-
* runtime starts. The result of this function is merged into the existing `definition`.
102+
* @param definitionFn A function that is injected before the app runtime starts.
103+
* The result of this function should be a [[ParamTypeDefinition]].
104+
* The result is merged into the existing `definition`.
101105
* See [[ParamType]] for information on the values accepted.
102106
*
103107
* @returns - if a type was registered: the [[UrlMatcherFactory]]
104108
* - if only the `name` parameter was specified: the currently registered [[ParamType]] object, or undefined
105109
*
106-
* This is a simple example of a custom type that encodes and decodes items from an
107-
* array, using the array index as the URL-encoded value:
110+
* Note: Register custom types *before using them* in a state definition.
111+
*
112+
* See [[ParamTypeDefinition]] for examples
108113
*/
109-
type(name: string, definition?: (Function|ParamType), definitionFn?: Function) {
114+
type(name: string, definition?: ParamTypeDefinition, definitionFn?: () => ParamTypeDefinition) {
110115
let type = paramTypes.type(name, definition, definitionFn);
111116
return !isDefined(definition) ? type : this;
112117
};

0 commit comments

Comments
 (0)