mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2025-04-28 14:04:45 +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 { Cordova, IonicNativePlugin, Plugin } from '@ionic-native/core';
|
||||||
import { Observable } from 'rxjs';
|
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
|
* @name Broadcaster
|
||||||
* @description
|
* @description
|
||||||
@ -35,6 +49,7 @@ export class Broadcaster extends IonicNativePlugin {
|
|||||||
/**
|
/**
|
||||||
* This function listen to an event sent from the native code
|
* This function listen to an event sent from the native code
|
||||||
* @param {string} eventName
|
* @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
|
* @return {Observable<any>} Returns an observable to watch when an event is received
|
||||||
*/
|
*/
|
||||||
@Cordova({
|
@Cordova({
|
||||||
@ -42,18 +57,22 @@ export class Broadcaster extends IonicNativePlugin {
|
|||||||
clearFunction: 'removeEventListener',
|
clearFunction: 'removeEventListener',
|
||||||
clearWithArgs: true,
|
clearWithArgs: true,
|
||||||
})
|
})
|
||||||
addEventListener(eventName: string): Observable<any> {
|
addEventListener(eventName: string, isGlobal = false): Observable<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function sends data to the native code
|
* This function sends data to the native code
|
||||||
* @param {string} eventName
|
* @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
|
* @return {Promise<any>} Returns a promise that resolves when an event is successfully fired
|
||||||
*/
|
*/
|
||||||
@Cordova()
|
@Cordova()
|
||||||
fireNativeEvent(eventName: string, eventData: any): Promise<any> {
|
fireNativeEvent(eventName: string, isGlobalOrEventData: boolean | EventData, data?: EventData): Promise<any> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user