The return type of the ResolveOnce instances (must include optional reset)
The key type (defaults to string)
Optional context type (defaults to empty object)
Plain type of T without reset (for internal use)
Creates a new KeyedResolvOnce instance.
Configuration options (key2string, ctx, lru)
Returns all resolved items with their values wrapped in Result.
Only includes items that have been resolved (ready state). Each item contains the key, Result-wrapped value, and full item metadata.
Array of all resolved items
Registers a callback that fires when a new ResolveOnce instance is created.
Callback receiving the key and ResolveOnce instance
Unregister function
Registers a callback that fires when a ResolveOnce instance is deleted.
Callback receiving the key and ResolveOnce instance
Unregister function
Updates the LRU parameters dynamically.
New LRU parameters
Asynchronously gets or creates a ResolveOnce for a key resolved from a promise.
Function returning a promise that resolves to the key
Promise resolving to the ResolveOnce instance
Gets or creates a ResolveOnce instance for the given key.
This is the primary method for accessing ResolveOnce instances. Each unique key gets its own instance that persists across calls.
The ResolveOnce instance for this key
Gets or creates the complete KeyedNgItem for a key.
Useful when you need access to the full item structure including metadata.
The complete KeyedNgItem
Deletes an entry from the collection.
Triggers onDelete callbacks before removal.
The key to delete
Resets and removes an entry from the collection.
Calls the optional reset() method on the value before deletion, allowing for cleanup operations.
The key to reset and delete
Resets all entries by calling their optional reset() methods.
Does not remove entries from the collection, only resets their state. Useful for cleanup without losing the collection structure.
Iterates over all completed entries, yielding key-result pairs.
Only yields entries that have been resolved (ready state). Values are wrapped in Result to distinguish success from error.
Keyed collection of ResolveOnce instances.
Manages a map of ResolveOnce instances indexed by keys, with optional LRU caching. Each key gets its own ResolveOnce instance that can be accessed and manipulated independently. Values can optionally have a reset() method for cleanup on deletion.
Example
Example