How to use the @esfx/cancelable.Cancelable.canceled 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-mutex / src / __tests__ / lock.ts View on Github external
it("throws when token is canceled", async () => {
        await expect(new AsyncMutex().lock(Cancelable.canceled)).rejects.toThrow(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));
                }
            }));