W3cubDocs

/RxJS

startWith

function stable

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.

startWith marble diagram

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

Type: SchedulerLike.

Returns

MonoTypeOperatorFunction<T>

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

Parameters

v1

Type: D.

scheduler

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

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

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

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

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

Type: SchedulerLike.

Returns

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

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

Parameters

v1

Type: D.

Returns

OperatorFunction<T, T | D>

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

Parameters

v1

Type: D.

v2

Type: E.

Returns

OperatorFunction<T, T | D | E>

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

Parameters

v1

Type: D.

v2

Type: E.

v3

Type: F.

Returns

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

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

Parameters

v1

Type: D.

v2

Type: E.

v3

Type: F.

v4

Type: G.

Returns

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

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

Parameters

v1

Type: D.

v2

Type: E.

v3

Type: F.

v4

Type: G.

v5

Type: H.

Returns

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

startWith(v1: D, v2: E, v3: F, v4: G, v5: H, v6: I): 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.

Returns

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

startWith(...array: D[]): OperatorFunction<T, T | D>

Parameters

array

Type: D[].

Returns

OperatorFunction<T, T | D>

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

Parameters

array

Type: Array.

Returns

OperatorFunction<T, T | D>

© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/operators/startWith