of

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.

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

Optional. Default is undefined.

Type: SchedulerLike.

Returns

Observable<T>

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

Parameters

a

Type: T.

b

Type: T2.

scheduler

Optional. Default is undefined.

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

Optional. Default is undefined.

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

Optional. Default is undefined.

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

Optional. Default is undefined.

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

Optional. Default is undefined.

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

Optional. Default is undefined.

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

Optional. Default is undefined.

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

Optional. Default is undefined.

Type: SchedulerLike.

Returns

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

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

Parameters

args

Type: Array.

Returns

Observable<T>

See Also