diff --git a/packages/ditox/README.md b/packages/ditox/README.md index 6c2c3b0..ef30e01 100644 --- a/packages/ditox/README.md +++ b/packages/ditox/README.md @@ -79,7 +79,7 @@ class UserService { } // Define tokens for injections. -const STORAGE_TOKEN = token('Token description for debugging'); +const STORAGE_TOKEN = token < UserService > 'Token description for debugging'; const LOGGER_TOKEN = token(); const USER_SERVICE_TOKEN = token(); @@ -164,15 +164,15 @@ Ditox.js supports managing the lifetime of values which are produced by factories. There are the following types: - `singleton` - **This is the default**. The value is created and cached by the - container which registered the factory. -- `scoped` - The value is created and cached by the container which starts - resolving. + most distant parent container which owns the factory function. +- `scoped` - The value is created and cached by the nearest container which owns + the factory function. - `transient` - The value is created every time it is resolved. ### `singleton` **This is the default scope**. "Singleton" allows to cache a produced value by a -parent container which registered the factory: +most distant parent container which registered the factory function: ```js import {creatContainer, token} from 'ditox'; diff --git a/packages/ditox/src/container.ts b/packages/ditox/src/container.ts index 1372a25..0edc62d 100644 --- a/packages/ditox/src/container.ts +++ b/packages/ditox/src/container.ts @@ -20,8 +20,8 @@ export type FactoryScope = 'scoped' | 'singleton' | 'transient'; * Options for factory binding. * * `scope` types: - * - `singleton` - **This is the default**. The value is created and cached by the container which registered the factory. - * - `scoped` - The value is created and cached by the container which starts resolving. + * - `singleton` - **This is the default**. The value is created and cached by the most distant parent container which owns the factory function. + * - `scoped` - The value is created and cached by the nearest container which owns the factory function. * - `transient` - The value is created every time it is resolved. * * `scoped` and `singleton` scopes can have `onRemoved` callback. It is called when a token is removed from the container. diff --git a/packages/ditox/src/modules.ts b/packages/ditox/src/modules.ts index 517179b..a0663b7 100644 --- a/packages/ditox/src/modules.ts +++ b/packages/ditox/src/modules.ts @@ -73,8 +73,8 @@ export type AnyModuleDeclaration = ModuleDeclaration>; * Options for module binding. * * `scope` types: - * - `singleton` - **This is the default**. The module is created and cached by the container which registered the factory. - * - `scoped` - The module is created and cached by the container which starts resolving. + * - `singleton` - **This is the default**. The value is created and cached by the most distant parent container which owns the factory function. + * - `scoped` - The value is created and cached by the nearest container which owns the factory function. */ export type BindModuleOptions = { scope?: 'scoped' | 'singleton';