Page Contents
Home > @loopback/context > compareBindingsByTag
compareBindingsByTag() function
Creates a binding compare function to sort bindings by tagged phase name.
Signature:
export declare function compareBindingsByTag(phaseTagName?: string, orderOfPhases?: (string | symbol)[]): BindingComparator;
Parameters
Parameter | Type | Description |
---|---|---|
phaseTagName | string | (Optional) Name of the binding tag for phase |
orderOfPhases | (string | symbol)[] | (Optional) An array of phase names as the predefined order |
Returns:
Remarks
Two bindings are compared as follows:
- Get values for the given tag as
phase
for bindings, if the tag is not present, defaultphase
to''
. 2. If both bindings havephase
value inorderOfPhases
, honor the order specified byorderOfPhases
. 3. If a binding’sphase
does not exist inorderOfPhases
, it comes before the one withphase
exists inorderOfPhases
. 4. If both bindings havephase
value outside oforderOfPhases
, they are ordered by phase names alphabetically and symbol values come before string values.