How to use the @esfx/cancelable.Cancelable.none 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 canBeSignaled(signal: CancelSignal) {
    return signal !== Cancelable.none && (!(signal instanceof CancelToken) || signal.canBeSignaled);
}
github esfx / esfx / packages / async-delay / src / index.ts View on Github external
return new Promise((resolve, reject) => {
        let msec: number;
        if (typeof cancelable === "number") {
            value = _msec as T | PromiseLike;
            msec = cancelable;
            cancelable = Cancelable.none;
        }
        else {
            msec = _msec as number;
        }

        Cancelable.throwIfSignaled(cancelable);

        const handle = setTimeout(() => {
            subscription.unsubscribe();
            resolve(value);
        }, msec);

        const subscription = Cancelable.subscribe(cancelable, () => {
            clearTimeout(handle);
            reject(new CancelError());
        });
github esfx / esfx / packages / async-canceltoken / src / index.ts View on Github external
subscribe(onSignaled) {
                    if (state === "closed") {
                        return Cancelable.none.subscribe(onSignaled);
                    }
                    if (state === "signaled") {
                        return Cancelable.canceled.subscribe(onSignaled);
                    }
                    const list = subscriptions || (subscriptions = new LinkedList());
                    return createCancelSubscription(list.push(onSignaled));
                }
            }));