Skip to content

[IMP] owl-core: add asyncComputed().currentPromise()#1963

Merged
mcm-odoo merged 1 commit into
masterfrom
feat-asynccomputed-currentpromise
Jun 24, 2026
Merged

[IMP] owl-core: add asyncComputed().currentPromise()#1963
mcm-odoo merged 1 commit into
masterfrom
feat-asynccomputed-currentpromise

Conversation

@ged-odoo

Copy link
Copy Markdown
Contributor

currentPromise() returns a promise that resolves as soon as no run is in flight: if a run is running it resolves once that run (or any run that supersedes it) settles, otherwise it resolves immediately. It never rejects — fetcher errors are surfaced through error().

This makes asyncComputed awaitable from onWillStart, to hold the first render until the initial data is ready:

onWillStart(() => this.data.currentPromise())

The in-flight run is tracked as a deferred that moves in lockstep with loading: created when a run begins, resolved when it settles. A re-run keeps the same deferred, so it resolves only once the latest run is no longer in flight. The deferred is resolved (never read) so it is safe to settle on the effect's synchronous path without registering a spurious dependency, and it is also resolved on dispose so awaiters never hang.

Documents the method on the Async Computed Values reference page.

`currentPromise()` returns a promise that resolves as soon as no run is in
flight: if a run is running it resolves once that run (or any run that
supersedes it) settles, otherwise it resolves immediately. It never rejects —
fetcher errors are surfaced through `error()`.

This makes asyncComputed awaitable from onWillStart, to hold the first render
until the initial data is ready:

  onWillStart(() => this.data.currentPromise())

In-flight state is tracked by a plain (non-reactive) flag mirroring `loading`,
so `currentPromise()` can read it without registering a dependency and
`dispose()` can mark the run abandoned without writing to the reactive signal.
The awaited promise is a deferred created lazily — only when a caller actually
asks for it during a run, so nothing is allocated when the feature is unused.
A re-run keeps the same deferred, so it resolves only once the latest run is
no longer in flight; it is resolved (never read) so settling on the effect's
synchronous path registers no spurious dependency, and it is also resolved on
dispose so awaiters never hang.

Documents the method on the Async Computed Values reference page.
@ged-odoo ged-odoo force-pushed the feat-asynccomputed-currentpromise branch from c5a5679 to 673a5b5 Compare June 24, 2026 14:30
@mcm-odoo mcm-odoo merged commit 99d4bdd into master Jun 24, 2026
2 checks passed
@mcm-odoo mcm-odoo deleted the feat-asynccomputed-currentpromise branch June 24, 2026 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants