Documents injecute 1.x · Migrating from 0.x
Skip to content

Interface: Tag()<T, N> ​

Defined in: src/types.ts:58

A tag, made by createTag: a name for an extension point. Calling it builds the key of a service under the tag (route('orders') is 'orders:route'); collect(tag) gives a factory every service registered under it, as an array of T.

Example ​

ts
export const route = createTag('route').of<Route>();

c.addSingleton(route('orders'), (): Route => ordersRoute); // the key 'orders:route'
c.addSingleton('router', (routes) => new Router(routes), [collect(route)]); // routes: Route[]

Type Parameters ​

T ​

T = unknown

N ​

N extends string = string

Tag<K>(name): `${K}:${N}` & TaggedKey<T, `${K}:${N}`>

Defined in: src/types.ts:63

The key of a service under this tag: name:<tag>. It carries the tag's type, so addSingleton() checks the service registered under it.

Type Parameters ​

K ​

K extends string

Parameters ​

name ​

K

Returns ​

`${K}:${N}` & TaggedKey<T, `${K}:${N}`>

Properties ​

[tagType]? ​

readonly optional [tagType]?: T

Defined in: src/types.ts:69

Type only: the type of the services under this tag.


tagName ​

readonly tagName: N

Defined in: src/types.ts:65

The tag's name: the suffix of the keys it builds.

Methods ​

of() ​

of<U>(): Tag<U, N>

Defined in: src/types.ts:67

The same tag, typed for services of type U: createTag('route').of<Route>().

Type Parameters ​

U ​

U

Returns ​

Tag<U, N>

Released under the MIT License.