GdlrDiContainer

Inherits: RefCounted < Object

Resolves providers and caches one value per token.

Description

Internal. GdlrModuleGraph creates one container per module. User code does not create containers.

Tutorials

Methods


Method Descriptions

void add_provider_factory(token: Variant, provider: GdlrDiContainer.ProviderFactory) 🔗

Registers the factory that creates the value for token.


GdbPromise resolve(token: Variant) 🔗

Resolves token and caches the value. Later calls return the cached value. Calls made while the first resolution is in flight share its promise, so the provider runs once. Failed resolutions are not cached; a later call retries the provider.


Variant resolve_sync(token: Variant) 🔗

Resolves token without waiting. Every provider in the dependency chain must be synchronous. The method returns the cached value when resolve() already ran.