BACK
ReferencestartWith
Reference · 31

startWith

startWith

rxjs.dev

Inserts one or more values at the start of the stream.

Signature

startWith(...values: T[]): MonoTypeOperatorFunction

Marble diagram

in:           ----1----2--|
startWith(0): 0---1----2--|

What it does

Synchronously emits the given values, then subscribes to the source and forwards everything it emits.

When to use

An initial value for combineLatest so the stream fires right away. A loading state before the first response: startWith({ loading: true }).

See also

endWith, concat, BehaviorSubject

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...