Module sync

Source
Expand description

Synchronization utilities

Type Aliases§

AnyFn

Type for any function

AwaitRet

Shorthand for Awaited<ReturnType<T>>

LatestUpdateArgsFn

See LatestConstructor

SerialCancelToken

The error type received by caller when an event is cancelled

SerialEventCancelCallback

The callback type passed to SerialEvent constructor to be called when the event is cancelled

Functions§

batch

An async event wrapper that allows multiple calls in an interval to be batched together.

debounce

An async event wrapper to execute a function with a minimal interval between calls.

latest

An async event wrapper that always resolve to the result of the latest call.

makePromise

Make a PromiseHandle with the promise object separate from its resolve and reject methods

once

An async event wrapper that ensures an async initialization is only ran once.

scopedCapture

Execute an async closure fn, and guarantee that obj will not be garbage-collected, until the promise is resolved.

scopedCaptureSync

Execute a closure fn, and guarantee that obj will not be garbage-collected during the execution

serial

An async event wrapper that is cancelled when a new one starts.

Classes§

RwLock

Ensure you have exclusive access in concurrent code

Interfaces§

BatchConstructor

Options to construct a batch function

DebounceConstructor

Options to construct a debounce function

LatestConstructor

Options to construct a latest function

OnceConstructor

Options to construct a once function

PromiseHandle

A handle of the promise that breaks down the promise object and its resolve and reject functions

SerialConstructor

Options to construct a serial function