Pointers and Registrators
Pointers#
A pointer in Brandi terminology is a unique value that is used for relating entities.
token<T>(description)#
Creates a unique token with the type.
Arguments#
- description:- stringโ a description of the token to be used in logs and error messages.
Returns#
Token<T> โ a unique token with the type.
Type Safety#
The token mechanism in Brandi provides type safety when binding and getting dependencies.
tag(description)#
Creates a unique tag.
Arguments#
- description:- stringโ a description of the tag to be used in logs and error messages.
Returns#
Tag โ a unique tag.
Registrators#
injected(target, ...tokens)#
Registers target injections.
Arguments#
- targetโ constructor or function whose dependencies will be injected.
- ...tokens:- TokenValue[]โ dependency tokens.
Returns#
target โ the first argument.
Example#
ApiService.ts
Type Safety#
Injections in Brandi are strictly typed.
tokens.ts
ApiService.ts
tagged(target, ...tags)#
Tags target. For more information about tags, see the Conditional Bindings documentation section.
Arguments#
- targetโ constructor or function that will be tagged.
- ...tags:- Tag[]โ tags.
Returns#
target โ the first argument.
Example#
ApiService.ts