W3cubDocs

/RxJS

of

function stable

Converts the arguments to an observable sequence.

of<T>(...args: Array<T | SchedulerLike>): Observable<T>

Parameters

args

Type: Array.

Returns

Observable<T>: An Observable that emits the arguments described above and then completes.

Description

Each argument becomes a next notification.

of marble diagram

Unlike from, it does not do any flattening and emits each argument in whole as a separate next notification.

Examples

Emit the values 10, 20, 30

import { of } from 'rxjs';

of(10, 20, 30)
.subscribe(
  next => console.log('next:', next),
  err => console.log('error:', err),
  () => console.log('the end'),
);
// result:
// 'next: 10'
// 'next: 20'
// 'next: 30'

Emit the array [1,2,3]

import { of } from 'rxjs';

of([1,2,3])
.subscribe(
  next => console.log('next:', next),
  err => console.log('error:', err),
  () => console.log('the end'),
);
// result:
// 'next: [1,2,3]'

Overloads

of(a: T, scheduler: SchedulerLike): Observable<T>

Parameters

a

Type: T.

scheduler

Type: SchedulerLike.

Returns

Observable<T>

of(a: T, b: T2, scheduler: SchedulerLike): Observable<T | T2>

Parameters

a

Type: T.

b

Type: T2.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2>

of(a: T, b: T2, c: T3, scheduler: SchedulerLike): Observable<T | T2 | T3>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2 | T3>

of(a: T, b: T2, c: T3, d: T4, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2 | T3 | T4>

of(a: T, b: T2, c: T3, d: T4, e: T5, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2 | T3 | T4 | T5>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6 | T7>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

g

Type: T7.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6 | T7>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

g

Type: T7.

h

Type: T8.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, i: T9, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

g

Type: T7.

h

Type: T8.

i

Type: T9.

scheduler

Type: SchedulerLike.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>

of(...args: (T | SchedulerLike)[]): Observable<T>

Parameters

args

Type: (T | SchedulerLike)[].

Returns

Observable<T>

of(a: T): Observable<T>

Parameters

a

Type: T.

Returns

Observable<T>

of(a: T, b: T2): Observable<T | T2>

Parameters

a

Type: T.

b

Type: T2.

Returns

Observable<T | T2>

of(a: T, b: T2, c: T3): Observable<T | T2 | T3>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

Returns

Observable<T | T2 | T3>

of(a: T, b: T2, c: T3, d: T4): Observable<T | T2 | T3 | T4>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

Returns

Observable<T | T2 | T3 | T4>

of(a: T, b: T2, c: T3, d: T4, e: T5): Observable<T | T2 | T3 | T4 | T5>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

Returns

Observable<T | T2 | T3 | T4 | T5>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6): Observable<T | T2 | T3 | T4 | T5 | T6>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7): Observable<T | T2 | T3 | T4 | T5 | T6 | T7>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

g

Type: T7.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6 | T7>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8): Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

g

Type: T7.

h

Type: T8.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8>

of(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, i: T9): Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>

Parameters

a

Type: T.

b

Type: T2.

c

Type: T3.

d

Type: T4.

e

Type: T5.

f

Type: T6.

g

Type: T7.

h

Type: T8.

i

Type: T9.

Returns

Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>

of(...args: T[]): Observable<T>

Parameters

args

Type: T[].

Returns

Observable<T>

See Also

© 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/index/function/of