-
Notifications
You must be signed in to change notification settings - Fork 0
RFC: Replace useAsyncComputed$ with a more flexible useAsync$ primitive #324
Copy link
Copy link
Closed
Labels
[STAGE-2] incomplete implementationRemove this label when implementation is completeRemove this label when implementation is complete[STAGE-2] not fully covered by tests yetRemove this label when tests are verified to cover the implementationRemove this label when tests are verified to cover the implementation[STAGE-2] unresolved discussions leftRemove this label when all critical discussions are resolved on the issueRemove this label when all critical discussions are resolved on the issue[STAGE-3] docs changes not added yetRemove this label when the necessary documentation for the feature / change is addedRemove this label when the necessary documentation for the feature / change is added[STAGE-3] missing 2 reviews for RFC PRsRemove this label when at least 2 core team members reviewed and approved the RFC implementationRemove this label when at least 2 core team members reviewed and approved the RFC implementation
Metadata
Metadata
Assignees
Labels
[STAGE-2] incomplete implementationRemove this label when implementation is completeRemove this label when implementation is complete[STAGE-2] not fully covered by tests yetRemove this label when tests are verified to cover the implementationRemove this label when tests are verified to cover the implementation[STAGE-2] unresolved discussions leftRemove this label when all critical discussions are resolved on the issueRemove this label when all critical discussions are resolved on the issue[STAGE-3] docs changes not added yetRemove this label when the necessary documentation for the feature / change is addedRemove this label when the necessary documentation for the feature / change is added[STAGE-3] missing 2 reviews for RFC PRsRemove this label when at least 2 core team members reviewed and approved the RFC implementationRemove this label when at least 2 core team members reviewed and approved the RFC implementation
Type
Projects
Status
Released as Stable (STAGE 5)
Champion
@Varixo and @wmertens
What's the motivation for this proposal?
Summary
Replace
useAsyncComputed$with a newuseAsync$that unifies async computation, observable values, polling, and eager cleanup, while aligning closer touseSignalsemantics.Motivation
Current
useAsyncComputed$overlaps withuseResource$but neither are great.A more powerful, writable async primitive would better support data fetching, streaming, auto-updating values, and background calculations.
Proposal
Rename
useAsyncComputed$touseAsync$:Key changes:
result.value = …updates subscribers directly; clears loading/error state.result.error = …propagates error on read.initialavoids throw when reading before first resolution.pollMs: numberoption orpoll(ms)callback for periodic re-execution; use.invalidate()as before to do it manually.Example
Benefits
useSignalmental model.useResource$or custom observables.Discussion points
pollbe an option, callback, both, or neither?Addition: generators
The callback should also be able to be a generator function, it should be wrapped so that every invocation updates the value.