[IMP] owl-core: add asyncComputed().currentPromise()#1963
Merged
Conversation
`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.
c5a5679 to
673a5b5
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 througherror().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.