Chainable firstValueFrom and lastValueFrom #7064
csisy
started this conversation in
Ideas / Feature request
Replies: 1 comment 1 reply
-
I don't fully understand the disadvantage of the current API... myObservable
.toPromise()
.then(...)
.then(...)
// vs
firstValueFrom(myObservable)
.then(...)
.then(...) For me, both of them are readable, although different. If anything, the current API is more concise on what actual value you want to get.... On the previous one if |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
Before
toPromise
was marked as deprecated in v7, the chaining calls were easy to read:It was especially nice if the observable was not stored in a variable (which is a pretty common case, e.g. Angular http requests that return an
Observable
).Now, the
firstValueFrom
andlastValueFrom
breaks the code flow, since the observable must be wrapped inside the function call. And even worse, if we need to use other parameters of these mentioned functions.I totally agree with the deprecation of
toPromise
, however, I think that both thefirstValueFrom
andlastValueFrom
should be part of theObservable
interface, just like thetoPromise
is.Compare the clunky wrapped code:
to the well-known, easier to format toPromise-like code:
However, in this case the function name should be a bit different, maybe removing
from
is enough.Beta Was this translation helpful? Give feedback.
All reactions