UNPKG

3.04 kBTypeScriptView Raw
1import { Observable } from 'rxjs/Observable';
2import { Subject } from 'rxjs/Subject';
3export { Observable } from 'rxjs/Observable';
4export { Subject } from 'rxjs/Subject';
5export { PromiseCompleter, PromiseWrapper } from './promise';
6export declare class TimerWrapper {
7 static setTimeout(fn: (...args: any[]) => void, millis: number): number;
8 static clearTimeout(id: number): void;
9 static setInterval(fn: (...args: any[]) => void, millis: number): number;
10 static clearInterval(id: number): void;
11}
12export declare class ObservableWrapper {
13 static subscribe<T>(emitter: any, onNext: (value: T) => void, onError?: (exception: any) => void, onComplete?: () => void): Object;
14 static isObservable(obs: any): boolean;
15 /**
16 * Returns whether `obs` has any subscribers listening to events.
17 */
18 static hasSubscribers(obs: EventEmitter<any>): boolean;
19 static dispose(subscription: any): void;
20 /**
21 * @deprecated - use callEmit() instead
22 */
23 static callNext(emitter: EventEmitter<any>, value: any): void;
24 static callEmit(emitter: EventEmitter<any>, value: any): void;
25 static callError(emitter: EventEmitter<any>, error: any): void;
26 static callComplete(emitter: EventEmitter<any>): void;
27 static fromPromise(promise: Promise<any>): Observable<any>;
28 static toPromise(obj: Observable<any>): Promise<any>;
29}
30/**
31 * Use by directives and components to emit custom Events.
32 *
33 * ### Examples
34 *
35 * In the following example, `Zippy` alternatively emits `open` and `close` events when its
36 * title gets clicked:
37 *
38 * ```
39 * @Component({
40 * selector: 'zippy',
41 * template: `
42 * <div class="zippy">
43 * <div (click)="toggle()">Toggle</div>
44 * <div [hidden]="!visible">
45 * <ng-content></ng-content>
46 * </div>
47 * </div>`})
48 * export class Zippy {
49 * visible: boolean = true;
50 * @Output() open: EventEmitter<any> = new EventEmitter();
51 * @Output() close: EventEmitter<any> = new EventEmitter();
52 *
53 * toggle() {
54 * this.visible = !this.visible;
55 * if (this.visible) {
56 * this.open.emit(null);
57 * } else {
58 * this.close.emit(null);
59 * }
60 * }
61 * }
62 * ```
63 *
64 * The events payload can be accessed by the parameter `$event` on the components output event
65 * handler:
66 *
67 * ```
68 * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
69 * ```
70 *
71 * Uses Rx.Observable but provides an adapter to make it work as specified here:
72 * https://github.com/jhusain/observable-spec
73 *
74 * Once a reference implementation of the spec is available, switch to it.
75 * @stable
76 */
77export declare class EventEmitter<T> extends Subject<T> {
78 __isAsync: boolean;
79 /**
80 * Creates an instance of [EventEmitter], which depending on [isAsync],
81 * delivers events synchronously or asynchronously.
82 */
83 constructor(isAsync?: boolean);
84 emit(value: T): void;
85 /**
86 * @deprecated - use .emit(value) instead
87 */
88 next(value: any): void;
89 subscribe(generatorOrNext?: any, error?: any, complete?: any): any;
90}
91
\No newline at end of file