UNPKG

4.3 kBTypeScriptView Raw
1/// <reference types="rx-core" />
2
3declare namespace Rx {
4 interface ISubject<T> extends Observable<T>, Observer<T>, IDisposable {
5 hasObservers(): boolean;
6 }
7
8 interface Subject<T> extends ISubject<T> {
9 }
10
11 interface SubjectStatic {
12 new<T>(): Subject<T>;
13 create<T>(observer?: Observer<T>, observable?: Observable<T>): ISubject<T>;
14 }
15
16 const Subject: SubjectStatic;
17
18 interface AsyncSubject<T> extends Subject<T> {
19 }
20
21 interface AsyncSubjectStatic {
22 new<T>(): AsyncSubject<T>;
23 }
24
25 const AsyncSubject: AsyncSubjectStatic;
26
27 interface BehaviorSubject<T> extends Subject<T> {
28 getValue(): T;
29 }
30
31 interface BehaviorSubjectStatic {
32 new<T>(initialValue: T): BehaviorSubject<T>;
33 }
34
35 const BehaviorSubject: BehaviorSubjectStatic;
36
37 interface ReplaySubject<T> extends Subject<T> {
38 }
39
40 interface ReplaySubjectStatic {
41 new<T>(bufferSize?: number, window?: number, scheduler?: IScheduler): ReplaySubject<T>;
42 }
43
44 const ReplaySubject: ReplaySubjectStatic;
45
46 interface ConnectableObservable<T> extends Observable<T> {
47 connect(): IDisposable;
48 refCount(): Observable<T>;
49 }
50
51 interface ConnectableObservableStatic {
52 new<T>(): ConnectableObservable<T>;
53 }
54
55 const ConnectableObservable: ConnectableObservableStatic;
56
57 interface Observable<T> {
58 multicast(subject: Observable<T>): ConnectableObservable<T>;
59 multicast<TResult>(
60 subjectSelector: () => ISubject<T>,
61 selector: (source: ConnectableObservable<T>) => Observable<T>,
62 ): Observable<T>;
63 publish(): ConnectableObservable<T>;
64 publish<TResult>(selector: (source: ConnectableObservable<T>) => Observable<TResult>): Observable<TResult>;
65 /**
66 * Returns an observable sequence that shares a single subscription to the underlying sequence.
67 * This operator is a specialization of publish which creates a subscription when the number of observers goes from zero to one,
68 * then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
69 *
70 * @example
71 * var res = source.share();
72 *
73 * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
74 */
75 share(): Observable<T>;
76 publishLast(): ConnectableObservable<T>;
77 publishLast<TResult>(selector: (source: ConnectableObservable<T>) => Observable<TResult>): Observable<TResult>;
78 publishValue(initialValue: T): ConnectableObservable<T>;
79 publishValue<TResult>(
80 selector: (source: ConnectableObservable<T>) => Observable<TResult>,
81 initialValue: T,
82 ): Observable<TResult>;
83 /**
84 * Returns an observable sequence that shares a single subscription to the underlying sequence and starts with an initialValue.
85 * This operator is a specialization of publishValue which creates a subscription when the number of observers goes from zero to one,
86 * then shares that subscription with all subsequent observers until the number of observers returns to zero, at which point the subscription is disposed.
87 *
88 * @example
89 * var res = source.shareValue(42);
90 *
91 * @param initialValue Initial value received by observers upon subscription.
92 * @returns An observable sequence that contains the elements of a sequence produced by multicasting the source sequence.
93 */
94 shareValue(initialValue: T): Observable<T>;
95 replay(
96 selector?: boolean,
97 bufferSize?: number,
98 window?: number,
99 scheduler?: IScheduler,
100 ): ConnectableObservable<T>; // hack to catch first omitted parameter
101 replay(
102 selector: (source: ConnectableObservable<T>) => Observable<T>,
103 bufferSize?: number,
104 window?: number,
105 scheduler?: IScheduler,
106 ): Observable<T>;
107 shareReplay(bufferSize?: number, window?: number, scheduler?: IScheduler): Observable<T>;
108 }
109}
110
111declare module "rx-core-binding" {
112 export = Rx;
113}
114
\No newline at end of file