* Cache the resolved value by the binding scope * @param resolutionCtx - The resolution context * @param result - The calculated value for the binding
(
resolutionCtx: Context,
result: ValueOrPromise<T>,
)
| 420 | * @param result - The calculated value for the binding |
| 421 | */ |
| 422 | private _cacheValue( |
| 423 | resolutionCtx: Context, |
| 424 | result: ValueOrPromise<T>, |
| 425 | ): ValueOrPromise<T> { |
| 426 | // Initialize the cache as a weakmap keyed by context |
| 427 | if (!this._cache) this._cache = new WeakMap<Context, ValueOrPromise<T>>(); |
| 428 | if (this.scope !== BindingScope.TRANSIENT) { |
| 429 | this._cache.set(resolutionCtx!, result); |
| 430 | } |
| 431 | return result; |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Clear the cache |