Function scopeGuard

  • Creates a scope guard that will invoke it's lambda when the function terminates. The scopeGuard must be created and assigned to a variable marked with the using keyword.

    using onExit = scopeGuard(() => console.log("Exiting scope"));
    

    Parameters

    • fnOnDispose: (() => void)

      The lambda to invoke when the object is being disposed.

        • (): void
        • Returns void

    Returns Disposable

    A Disposable object that can be used to dispose the object.