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.
Description:
This PR adds an
allValuesFrom
function that's similar tofirstValueFrom
andlastValueFrom
, but the promise resolves to an array of all the values emitted by the observable, instead of just the first or last. (UnlikefirstValueFrom
andlastValueFrom
, it's not an error if the observable completes without emitting anything: the promise just resolves to an empty array in that case.)The implementation is a trivial combination of the
toArray
operator with eitherfirstValueFrom
orlastValueFrom
(they're equivalent when used withtoArray
), and applications can easily accomplish the same thing directly by using an expression likefirstValueFrom(anObservable.pipe(..., toArray()))
, but the interaction between the two might not be clear to a reader — especially since thetoArray()
could be at the end of a lengthy multi-line pipe, distant from thefirstValueFrom
. Putting the combination into a function namedallValuesFrom
makes it obvious what the result will be. And although applications can easily implement the function themselves, it's closely related tofirstValueFrom
andlastValueFrom
so I think it makes sense for the library to provide it.The jsdoc and tests are adapted from the ones for
firstValueFrom
andlastValueFrom
, so similar in structure.