UNPKG

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