ReferencedefaultIfEmpty
Reference · 54
defaultIfEmpty
defaultIfEmpty
Substitutes a value if the source completes without emitting.
Signature
defaultIfEmpty(defaultValue: R): OperatorFunction
What it does
It tracks whether any value arrived. If source completes empty, it emits defaultValue and completes the stream.
When to use
Empty search results, a fallback for filters, safe aggregation after first/last/find.
See also
isEmpty, throwIfEmpty, EMPTY
script.ts
CONSOLE · Console output
Hit Run to see the result...