Skip to content
Shapemetry

@huukhanhnguyen/model / core/maybeAsync

core/maybeAsync

isThenable()

isThenable(value): value is PromiseLike<unknown>

Parameters

value

unknown

Returns

value is PromiseLike<unknown>


pull()

pull<T>(cell, compute, commit, onError, onSuperseded?): void

Run compute(), committing its (possibly later-arriving) result via commit/onError. isAsync tells the callback whether this is the deferred settle (needs a cascade to reach dependents) or the inline settle (already part of a synchronous pull — nothing more to push).

Type Parameters

T

T

Parameters

cell

PullCell

compute

() => T | Promise<T>

commit

(value, isAsync) => void

onError

(err, isAsync) => void

onSuperseded?

() => void

Called INSTEAD of commit/onError when a newer dirty superseded this attempt while it was in flight. The attempt produced neither a value nor an error, but it did END — without this, an observer that opened on entry could never close (see nodes/hooks.ts's beginEvaluate).

Returns

void


reduceMaybeAsync()

reduceMaybeAsync<S, Item>(initial, items, fn): S | Promise<S>

Thread a chain of steps where each step's output is the next step's input (the modifier chain). Stays synchronous until the first step returns a thenable; every step after that chains via .then — a resolved promise's .then is always a microtask, so there's no rejoining the sync path mid-chain.

Type Parameters

S

S

Item

Item

Parameters

initial

S

items

Item[]

fn

(state, item) => S | Promise<S>

Returns

S | Promise<S>


scheduleRewalk()

scheduleRewalk(owner): void

Microtask-coalesced trigger for a full top-level re-walk (the same owner.nodes.evaluate() entry point ExpressionNode.requestEvaluate() already uses for "user edited a field"). N async settles landing in the same tick cause one re-walk, not N.

Parameters

owner

Rewalkable | null | undefined

Returns

void

Last updated: 📖 2 min readEdit on GitHub