Skip to content

Commit

Permalink
feat(broadcaster): align plugin API to version 4.1.0 (#3432)
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino authored Jun 11, 2020
1 parent 389a3fb commit 324334e
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions src/@ionic-native/plugins/broadcaster/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import { Injectable } from '@angular/core';
import { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
import { Observable } from 'rxjs';

/**
* Specific data for Android implementation
*/
export interface AndroidData {
extras: object;
flags: number;
category: string;
}

/**
* Possibly Event Data types
*/
export type EventData = object | AndroidData | null;

/**
* @name Broadcaster
* @description
Expand Down Expand Up @@ -35,25 +49,30 @@ export class Broadcaster extends IonicNativePlugin {
/**
* This function listen to an event sent from the native code
* @param {string} eventName
* @param {boolean} isGlobal Valid only for Android. It allows to listen for global messages(i.e. intents)
* @return {Observable<any>} Returns an observable to watch when an event is received
*/
@Cordova({
observable: true,
clearFunction: 'removeEventListener',
clearWithArgs: true,
})
addEventListener(eventName: string): Observable<any> {
addEventListener(eventName: string, isGlobal = false): Observable<any> {
return;
}

/**
* This function sends data to the native code
* @param {string} eventName
* @param {any} eventData
* @param {boolean} isGlobalOrEventData means that message is global (valid only on Android)
* @param {AndroidData} isGlobalOrEventData allows to specify 'flags` and 'category' (valid only on Android)
* @param {object} isGlobalOrEventData allows to specify a generic object containing custom event data (all platform)
* @param {AndroidData} [data] if isGlobal is set, allows to specify 'flags` and 'category' if isGlobal is set (valid only on Android)
* @param {object} [data] if isGlobal is set, allows to specify a generic object containing custom event data (all platform)
* @return {Promise<any>} Returns a promise that resolves when an event is successfully fired
*/
@Cordova()
fireNativeEvent(eventName: string, eventData: any): Promise<any> {
fireNativeEvent(eventName: string, isGlobalOrEventData: boolean | EventData, data?: EventData): Promise<any> {
return;
}
}

0 comments on commit 324334e

Please sign in to comment.