How to use the @esfx/cancelable.CancelSubscription.create function in @esfx/cancelable

To help you get started, we’ve selected a few @esfx/cancelable examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github esfx / esfx / packages / async-canceltoken / src / index.ts View on Github external
function createCancelSubscription(node: LinkedListNode<() => void>): CancelSubscription {
    return CancelSubscription.create(() => {
        if (node.detachSelf()) {
            node.value = undefined!;
        }
    });
}
github esfx / esfx / packages / cancelable-dom-shim / src / index.ts View on Github external
subscribe(onCancellationRequested): CancelSubscription {
                let callback = () => onCancellationRequested();
                abortSignal.addEventListener("abort", callback);
                return CancelSubscription.create(() => {
                    if (callback && abortSignal) {
                        abortSignal.removeEventListener("abort", callback);
                        callback = undefined!;
                    }
                });
            }
        };