useOptionalDisposable Function

A custom hook which calls the factory method to create a disposable object which might as well be undefined. If the result was a disposable object, the hook takes care of disposing it when necessary.

useOptionalDisposable<TDisposable extends IDisposable>(createDisposable: () => undefined | TDisposable): TDisposable | undefined

Parameter Type Description
createDisposable () => undefined | TDisposable  

Returns - TDisposable | undefined

Defined in

Last Updated: 05 April, 2024