[FeatureRequest] asyncComputed
#91
Replies: 9 comments 3 replies
-
Update: Because |
Beta Was this translation helpful? Give feedback.
-
I am thinking about supporting this to an extent with FutureSignal. The only signals that would be subscribed would be anything before an async gap. Would love to add a lint like BuildContext and async. This would essentially give the future function passed a computed signal to listen to changes. |
Beta Was this translation helpful? Give feedback.
-
FutureSignal also allows for unwrapping via I am still looking how to best support async computed. The issue is the state graph is sync and introducing async will then require all the signals to be awaited which can take away some of the benefits. I think it would be possible to have a async computed with an explicit list of signals to listen for since anything past the async boundary would not be captured. |
Beta Was this translation helpful? Give feedback.
-
So far in my use of Note that in some cases I need to do things like: // List dependencies without awaiting them here
final futureA = someDerivedFuture.future;
final futureB = someOtherDerivedFuture.future;
// Await all at same time for speed
final results = await (futureA, futureB).wait;
final typedA = results.$1;
final typedB = results.$2;
// Or, await each one after the other if one depends on another
... |
Beta Was this translation helpful? Give feedback.
-
Something that can start to get closer to what you want is the new signal container: You could combine it with |
Beta Was this translation helpful? Give feedback.
-
Going to move this to a discussion to discuss options about a possible API or approaches. |
Beta Was this translation helpful? Give feedback.
-
Working on addressing this with the following PR: |
Beta Was this translation helpful? Give feedback.
-
I really like what Angular is doing with signals and asyncComputed, we can copy the API using FutureSignal and AsyncSignal: https://twitter.com/Enea_Jahollari/status/1749772921105469839 |
Beta Was this translation helpful? Give feedback.
-
Added computedAsync / computedFrom on 4.0.0 🎉 |
Beta Was this translation helpful? Give feedback.
-
I'm just formalizing the discussion happening in #52 (which has been marked as answered) with a request for
asyncComputed
. In #52 (comment) I linked agist
that details my use case. Basically I need everycomputed
in that class to be anasyncComputed
. I find the need to callresetFuture
orresetStream
on anasyncSignal
pretty cumbersome when the dependencies of acomputed
may be more than one. Having acomputed
value that can beasync
and avoids race conditions with its dependencies would be amazing when paired with allowing for anon-null
type wrapped byAsyncSignal
without a default value (as is discussed here and here (I think)).Signals are new to me, so I may be asking too much or for something that doesn't feel natural in signals, so please feel free to point that out.
Beta Was this translation helpful? Give feedback.
All reactions