Files
website/src/content/docs/v3/api/functions/Service.md
2025-01-24 07:41:47 +01:00

917 B

editUrl, next, prev, title
editUrl next prev title
false false false Service

Service<T>(key): NonNullable<UnpackFunction<Partial<Dependencies>[T]>>

The new Service api, a cleaner alternative to useContainer To obtain intellisense, ensure a .d.ts file exists in the root of compilation. Usually our scaffolding tool takes care of this. Note: this method only works AFTER your container has been initiated

Type parameters

T extends keyof Dependencies

Parameters

key: T

a key that corresponds to a dependency registered.

Returns

NonNullable<UnpackFunction<Partial<Dependencies>[T]>>

Since

3.0.0

Example

const client = Service('@sern/client');

Source

src/core/ioc/dependency-injection.ts:37