A Disposable Map is an IDisposable store that manages Disposers and IDisposables with keys.
All Disposers and IDisposables in the Map will be invoked(flush
) when the Map is disposed.
A DisposableMap is also a Disposer, which means it can be the dispose
method of an IDisposable.
A DisposableMap is also an IDisposable, which means it can be managed by another DisposableMap.
Flush and clear all of the Disposers and IDisposables in the Map.
Invoke the DisposableType and remove it from the Map at the specific key.
Optional
key: DisposableKeyMap key of the DisposableType. Flush all if omitted.
Check if a DisposableType at the specific key is in the Map.
true
if exists, otherwise false
.
Map key of the DisposableType.
Invoke the executor function and add the returned DisposableType to the Map at the specific key.
Adding DisposableType to the same key will first invoke(flush
) the previous DisposableType at that key.
The returned DisposableType.
Key for the DisposableType. Adding with same key will first invoke(flush
) the previous DisposableType.
A function that returns a DisposableType.
Invoke the executor function and add the returned DisposableType to the Map at the specific key.
Do nothing if null | undefined
is returned or the returned DisposableType is already in the Map.
Adding DisposableType to the same key will first invoke(flush
) the previous DisposableType at that key.
The returned DisposableType, or undefined
if the executor returns null | undefined
.
Key for the DisposableType. Adding with same key will first invoke(flush
) the previous DisposableType.
A function that returns either a DisposableType or null | undefined
.
Remove the DisposableType at the specific key from the Map. Does not invoke the removed DisposableType.
The removed DisposableType if exists, undefined
if the DisposableType is not found.
Map key of the DisposableType.
Set a DisposableType to the Map at the specific key.
Adding DisposableType to the same key will first invoke(flush
) the previous DisposableType at that key.
The same DisposableType .
Key for the DisposableType. Adding with same key will first invoke(flush
) the previous DisposableType.
A DisposableType .
Get the number of DisposableTypes in the Map.
Flush and clear all of the Disposers and IDisposables in the Map.