DisposableOne is an IDisposable that manages a single Disposer or IDisposable.
The current Disposer and IDisposable in DisposableOne will be invoked(flush
) when setting a new one.
A DisposableOne is also a Disposer, which means it can be the dispose
method of an IDisposable.
Optional
currentThe current DisposableType.
Flush the current Disposer and IDisposable and remove it.
Invoke the current DisposableType and remove it.
Check if the DisposableType is the current one.
true
if the DisposableType is the current one, otherwise false
.
The DisposableType.
Invoke the executor function and set the returned DisposableType.
Do nothing if the DisposableType already exists.
The returned DisposableType.
A function that returns a DisposableType.
Invoke the executor function and set the returned DisposableType.
Do nothing if null | undefined
is returned or the returned DisposableType already exists.
The returned DisposableType, or undefined
if the executor returns undefined | null
.
A function that returns either a DisposableType or undefined | null
.
Invoke the executor function and set the returned DisposableType. Do nothing if undefined | null
is returned.
Do nothing if the DisposableType already exists.
The DisposableType, or undefined
if the executor returns undefined | null
.
A function that returns either a DisposableType or undefined | null
.
Remove the current DisposableType. Does not invoke the removed DisposableType.
true
if a DisposableType exists and removed, otherwise false
.
Set a DisposableType.
Do nothing if the same DisposableType already exists.
Existing DisposableType will be flushed before setting a new one.
The same DisposableType .
A DisposableType .
Flush and remove the current Disposer and IDisposable.