• Enhance a Disposer so that it can be safely self-disposed.

    If it is attached to a DisposableStore, it will be removed from the store automatically when self-disposed.

    Returns

    An abortable DisposableDisposer.

    Example

    let timeoutId;
    const disposer = abortable(() => clearTimeout(timeoutId));
    timeoutId = setTimeout(() => console.log("hello"), 1000);

    // Add to a store
    const disposable = new DisposableStore();
    disposable.add(disposer);

    // Self-dispose
    disposer(); // setTimeout is cleared and the disposer is removed from the store.

    Parameters

    • disposer: (() => any)
        • (): any
        • Returns any

    Returns DisposableDisposer<any>