On this page
of
function
deprecated
Deprecation Notes
The scheduler
parameter will be removed in v8. Use scheduled
. Details: https://rxjs.dev/deprecations/scheduler-argument
of<A extends readonly, unknown>()
Parameters
There are no parameters.
Overloads
of(value: null): Observable<null>
Parameters
value |
null |
Returns
Observable<null>
of(value: undefined): Observable<undefined>
Parameters
value |
undefined |
Returns
Observable<undefined>
of(scheduler: SchedulerLike): Observable<never>
Parameters
scheduler |
SchedulerLike |
Returns
Observable<never>
of(): Observable<never>
Parameters
There are no parameters.
Returns
Observable<never>
of(): Observable<T>
Parameters
There are no parameters.
Returns
of(value: T): Observable<T>
Parameters
value |
T |
Returns
of()
Parameters
There are no parameters.
of(...args: (SchedulerLike | T)[]): Observable<T>
Converts the arguments to an observable sequence.
Parameters
args |
(SchedulerLike | T)[] |
Returns
Observable<T>
: An Observable that emits the arguments described above and then completes.
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: value => console.log('next:', value),
error: err => console.log('error:', err),
complete: () => console.log('the end'),
});
// Outputs
// next: 10
// next: 20
// next: 30
// the end
Emit the array [1, 2, 3]
import { of } from 'rxjs';
of([1, 2, 3])
.subscribe({
next: value => console.log('next:', value),
error: err => console.log('error:', err),
complete: () => console.log('the end'),
});
// Outputs
// next: [1, 2, 3]
// the end
© 2015–2022 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