1 | import { SchedulerLike } from '../types';
|
---|
2 | import { isScheduler } from '../util/isScheduler';
|
---|
3 | import { fromArray } from './fromArray';
|
---|
4 | import { Observable } from '../Observable';
|
---|
5 | import { scheduleArray } from '../scheduled/scheduleArray';
|
---|
6 |
|
---|
7 | /* tslint:disable:max-line-length */
|
---|
8 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
9 | export function of<T>(a: T, scheduler: SchedulerLike): Observable<T>;
|
---|
10 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
11 | export function of<T, T2>(a: T, b: T2, scheduler: SchedulerLike): Observable<T | T2>;
|
---|
12 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
13 | export function of<T, T2, T3>(a: T, b: T2, c: T3, scheduler: SchedulerLike): Observable<T | T2 | T3>;
|
---|
14 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
15 | export function of<T, T2, T3, T4>(a: T, b: T2, c: T3, d: T4, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4>;
|
---|
16 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
17 | export function of<T, T2, T3, T4, T5>(a: T, b: T2, c: T3, d: T4, e: T5, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5>;
|
---|
18 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
19 | export function of<T, T2, T3, T4, T5, T6>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, scheduler: SchedulerLike): Observable<T | T2 | T3 | T4 | T5 | T6>;
|
---|
20 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
21 | export function of<T, T2, T3, T4, T5, T6, T7>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, scheduler: SchedulerLike):
|
---|
22 | Observable<T | T2 | T3 | T4 | T5 | T6 | T7>;
|
---|
23 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
24 | export function of<T, T2, T3, T4, T5, T6, T7, T8>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, scheduler: SchedulerLike):
|
---|
25 | Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
|
---|
26 | /** @deprecated use {@link scheduled} instead `scheduled([a, b, c], scheduler)` */
|
---|
27 | export function of<T, T2, T3, T4, T5, T6, T7, T8, T9>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, i: T9, scheduler: SchedulerLike):
|
---|
28 | Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
|
---|
29 | export function of<T>(...args: (T | SchedulerLike)[]): Observable<T>;
|
---|
30 |
|
---|
31 | // TODO(benlesh): Update the typings for this when we can switch to TS 3.x
|
---|
32 | export function of<T>(a: T): Observable<T>;
|
---|
33 | export function of<T, T2>(a: T, b: T2): Observable<T | T2>;
|
---|
34 | export function of<T, T2, T3>(a: T, b: T2, c: T3): Observable<T | T2 | T3>;
|
---|
35 | export function of<T, T2, T3, T4>(a: T, b: T2, c: T3, d: T4): Observable<T | T2 | T3 | T4>;
|
---|
36 | export function of<T, T2, T3, T4, T5>(a: T, b: T2, c: T3, d: T4, e: T5): Observable<T | T2 | T3 | T4 | T5>;
|
---|
37 | export function of<T, T2, T3, T4, T5, T6>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6): Observable<T | T2 | T3 | T4 | T5 | T6>;
|
---|
38 | export function of<T, T2, T3, T4, T5, T6, T7>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7):
|
---|
39 | Observable<T | T2 | T3 | T4 | T5 | T6 | T7>;
|
---|
40 | export function of<T, T2, T3, T4, T5, T6, T7, T8>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8):
|
---|
41 | Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8>;
|
---|
42 | export function of<T, T2, T3, T4, T5, T6, T7, T8, T9>(a: T, b: T2, c: T3, d: T4, e: T5, f: T6, g: T7, h: T8, i: T9):
|
---|
43 | Observable<T | T2 | T3 | T4 | T5 | T6 | T7 | T8 | T9>;
|
---|
44 | export function of<T>(...args: T[]): Observable<T>;
|
---|
45 | /* tslint:enable:max-line-length */
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * Converts the arguments to an observable sequence.
|
---|
49 | *
|
---|
50 | * <span class="informal">Each argument becomes a `next` notification.</span>
|
---|
51 | *
|
---|
52 | * ![](of.png)
|
---|
53 | *
|
---|
54 | * Unlike {@link from}, it does not do any flattening and emits each argument in whole
|
---|
55 | * as a separate `next` notification.
|
---|
56 | *
|
---|
57 | * ## Examples
|
---|
58 | *
|
---|
59 | * Emit the values `10, 20, 30`
|
---|
60 | *
|
---|
61 | * ```ts
|
---|
62 | * import { of } from 'rxjs';
|
---|
63 | *
|
---|
64 | * of(10, 20, 30)
|
---|
65 | * .subscribe(
|
---|
66 | * next => console.log('next:', next),
|
---|
67 | * err => console.log('error:', err),
|
---|
68 | * () => console.log('the end'),
|
---|
69 | * );
|
---|
70 | * // result:
|
---|
71 | * // 'next: 10'
|
---|
72 | * // 'next: 20'
|
---|
73 | * // 'next: 30'
|
---|
74 | *
|
---|
75 | * ```
|
---|
76 | *
|
---|
77 | * Emit the array `[1,2,3]`
|
---|
78 | *
|
---|
79 | * ```ts
|
---|
80 | * import { of } from 'rxjs';
|
---|
81 | *
|
---|
82 | * of([1,2,3])
|
---|
83 | * .subscribe(
|
---|
84 | * next => console.log('next:', next),
|
---|
85 | * err => console.log('error:', err),
|
---|
86 | * () => console.log('the end'),
|
---|
87 | * );
|
---|
88 | * // result:
|
---|
89 | * // 'next: [1,2,3]'
|
---|
90 | * ```
|
---|
91 | *
|
---|
92 | * @see {@link from}
|
---|
93 | * @see {@link range}
|
---|
94 | *
|
---|
95 | * @param {...T} values A comma separated list of arguments you want to be emitted
|
---|
96 | * @return {Observable} An Observable that emits the arguments
|
---|
97 | * described above and then completes.
|
---|
98 | * @method of
|
---|
99 | * @owner Observable
|
---|
100 | */
|
---|
101 |
|
---|
102 | export function of<T>(...args: Array<T | SchedulerLike>): Observable<T> {
|
---|
103 | let scheduler = args[args.length - 1] as SchedulerLike;
|
---|
104 | if (isScheduler(scheduler)) {
|
---|
105 | args.pop();
|
---|
106 | return scheduleArray(args as T[], scheduler);
|
---|
107 | } else {
|
---|
108 | return fromArray(args as T[]);
|
---|
109 | }
|
---|
110 | }
|
---|