firstValueFrom and lastValueFrom defaultValue type #6278
jakovljevic-mladen
started this conversation in
Ideas / Feature request
Replies: 1 comment 4 replies
-
If/when |
Beta Was this translation helpful? Give feedback.
4 replies
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.
-
Hi all. I'd like to discuss the type of the
defaultValue
parameters fromFirstValueFromConfig
andLastValueFromConfig
interfaces.Based on this comment, there is a strong possibility that a new
signal
property will be added to these interfaces. Most probably,defaultValue
will become optional so users don't have to provide it if they only want to provide an abortion signal, like this:firstValueFrom(source$, { signal: ac.signal });
.In that case, it won't be possible to allow promises to resolve with
undefined
instead of a promise erroring with anEmptyError
if nothing has been sent through the stream. With current set up, it is possible to write this:firstValueFrom(source, { defaultValue: undefined });
and ifsource
isEMPTY
, it will resolve a promise withundefined
.I'd like to propose
defaultValue
to be renamed todefault
and to become an object with avalue
property. IffirstValueFrom
orlastValueFrom
receive an object, they will emit the default value from avalue
property of that object.So,
firstValueFrom(EMPTY, { signal: ac.signal });
would reject a promise withEmptyError
.But,
firstValueFrom(EMPTY, { default: {}, signal: ac.signal });
(orfirstValueFrom(EMPTY, { default: { value: undefined }, signal: ac.signal });
) would resolve a promise withundefined
.Beta Was this translation helpful? Give feedback.
All reactions