mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-01-19 00:12:53 +08:00
feat(broadcaster): align plugin API to version 4.1.0 (#3432)
This commit is contained in:
parent
389a3fb215
commit
324334eb28
@ -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
|
||||
@ -35,6 +49,7 @@ 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({
|
||||
@ -42,18 +57,22 @@ export class Broadcaster extends IonicNativePlugin {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user