1 | import { Observable } from 'rxjs/Observable';
|
2 | /**
|
3 | * @name Broadcaster
|
4 | * @description
|
5 | * This plugin adds exchanging events between native code and your app.
|
6 | *
|
7 | * @usage
|
8 | * ```
|
9 | * import { Broadcaster } from 'ionic-native';
|
10 | *
|
11 | * // Listen to events from Native
|
12 | * Broadcaster.addEventListener('eventName').then((event) => console.log(event));
|
13 | *
|
14 | * // Send event to Native
|
15 | * Broadcaster.fireNativeEvent('eventName', {}).then(() => console.log('success'));
|
16 | *
|
17 | * ```
|
18 | */
|
19 | export declare class Broadcaster {
|
20 | /**
|
21 | * This function listen to an event sent from the native code
|
22 | * @param eventName {string}
|
23 | * @return {Observable<any>} Returns an observable to watch when an event is received
|
24 | */
|
25 | static addEventListener(eventName: string): Observable<any>;
|
26 | /**
|
27 | * This function sends data to the native code
|
28 | * @param eventName {string}
|
29 | * @param eventData {any}
|
30 | * @return {Promise<any>} Returns a promise that resolves when an event is successfully fired
|
31 | */
|
32 | static fireNativeEvent(eventName: string, eventData: any): Promise<any>;
|
33 | }
|