startWith

Returns an Observable that emits the items you specify as arguments before it begins to emit items emitted by the source Observable.

startWith<T, D>(...array: Array<T | SchedulerLike>): OperatorFunction<T, T | D>

Parameters

array

Type: Array.

Returns

OperatorFunction<T, T | D>: An Observable that emits the items in the specified Iterable and then emits the items emitted by the source Observable.

Description

First emits its arguments in order, and then any emissions from the source.

Examples

Start the chain of emissions with "first", "second"

import { of } from 'rxjs'; import { startWith } from 'rxjs/operators'; of("from source") .pipe(startWith("first", "second")) .subscribe(x => console.log(x)); // results: // "first" // "second" // "from source"

Overloads

startWith(scheduler?: SchedulerLike): MonoTypeOperatorFunction<T>

Parameters

scheduler

Optional. Default is undefined.

Type: SchedulerLike.

Returns

MonoTypeOperatorFunction<T>

startWith(v1: D, scheduler?: SchedulerLike): OperatorFunction<T, T | D>

Parameters

v1

Type: D.

scheduler

Optional. Default is undefined.

Type: SchedulerLike.

Returns

OperatorFunction<T, T | D>

startWith(v1: D, v2: E, scheduler?: SchedulerLike): OperatorFunction<T, T | D | E>

Parameters

v1

Type: D.

v2

Type: E.

scheduler

Optional. Default is undefined.

Type: SchedulerLike.

Returns

OperatorFunction<T, T | D | E>

startWith(v1: D, v2: E, v3: F, scheduler?: SchedulerLike): OperatorFunction<T, T | D | E | F>

Parameters

v1

Type: D.

v2

Type: E.

v3

Type: F.

scheduler

Optional. Default is undefined.

Type: SchedulerLike.

Returns

OperatorFunction<T, T | D | E | F>

startWith(v1: D, v2: E, v3: F, v4: G, scheduler?: SchedulerLike): OperatorFunction<T, T | D | E | F | G>

Parameters

v1

Type: D.

v2

Type: E.

v3

Type: F.

v4

Type: G.

scheduler

Optional. Default is undefined.

Type: SchedulerLike.

Returns

OperatorFunction<T, T | D | E | F | G>

startWith(v1: D, v2: E, v3: F, v4: G, v5: H, scheduler?: SchedulerLike): OperatorFunction<T, T | D | E | F | G | H>

Parameters

v1

Type: D.

v2

Type: E.

v3

Type: F.

v4

Type: G.

v5

Type: H.

scheduler

Optional. Default is undefined.

Type: SchedulerLike.

Returns

OperatorFunction<T, T | D | E | F | G | H>

startWith(v1: D, v2: E, v3: F, v4: G, v5: H, v6: I, scheduler?: SchedulerLike): OperatorFunction<T, T | D | E | F | G | H | I>

Parameters

v1

Type: D.

v2

Type: E.

v3

Type: F.

v4

Type: G.

v5

Type: H.

v6

Type: I.

scheduler

Optional. Default is undefined.

Type: SchedulerLike.

Returns

OperatorFunction<T, T | D | E | F | G | H | I>

startWith(...array: Array<D | SchedulerLike>): OperatorFunction<T, T | D>

Parameters

array

Type: Array.

Returns

OperatorFunction<T, T | D>