File tree Expand file tree Collapse file tree 3 files changed +6
-14
lines changed Expand file tree Collapse file tree 3 files changed +6
-14
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ export interface PortalsPlugin {
9
9
) : Promise < void > ;
10
10
addListener < T = unknown > (
11
11
eventName : string ,
12
- listenerFunc : SubscriptionCallback < T > ,
12
+ listenerFunc : ( result : PortalMessage < T > ) => void ,
13
13
) : Promise < PluginListenerHandle > & PluginListenerHandle ;
14
14
}
15
15
@@ -31,11 +31,3 @@ export interface PortalMessage<TData = any> {
31
31
topic : string ;
32
32
data ?: TData ;
33
33
}
34
-
35
- /**
36
- * The type definition from the callback running Portals.subscribe()
37
- */
38
- export type SubscriptionCallback < T = unknown > = ( result : {
39
- topic : string ;
40
- data : T ;
41
- } ) => void ;
Original file line number Diff line number Diff line change @@ -5,7 +5,6 @@ import type {
5
5
InitialContext ,
6
6
PortalMessage ,
7
7
PortalsPlugin ,
8
- SubscriptionCallback ,
9
8
} from './definitions' ;
10
9
11
10
const Portals = registerPlugin < PortalsPlugin > ( 'Portals' , {
@@ -20,17 +19,18 @@ const Portals = registerPlugin<PortalsPlugin>('Portals', {
20
19
export function getInitialContext < T = unknown > ( ) :
21
20
| InitialContext < T >
22
21
| undefined {
23
- if ( Capacitor . getPlatform ( ) === "android" ) {
22
+ if ( Capacitor . getPlatform ( ) === 'android' ) {
23
+ // eslint-disable-next-line
24
24
//@ts -ignore
25
- return JSON . parse ( AndroidInitialContext . initialContext ( ) )
25
+ return JSON . parse ( AndroidInitialContext . initialContext ( ) ) ;
26
26
} else {
27
27
return ( window as any ) . portalInitialContext ;
28
28
}
29
29
}
30
30
31
31
export function subscribe < T = unknown > (
32
32
topic : string ,
33
- callback : SubscriptionCallback < T > ,
33
+ callback : ( result : PortalMessage < T > ) => void ,
34
34
) : Promise < PluginListenerHandle > {
35
35
return Portals . addListener ( topic , callback ) ;
36
36
}
Original file line number Diff line number Diff line change @@ -4,5 +4,5 @@ import type { PortalMessage, PortalsPlugin } from './definitions';
4
4
5
5
export class PortalsWeb extends WebPlugin implements PortalsPlugin {
6
6
// eslint-disable-next-line
7
- async publishNative ( _message : PortalMessage ) : Promise < void > { }
7
+ async publishNative ( _message : PortalMessage ) : Promise < void > { }
8
8
}
You can’t perform that action at this time.
0 commit comments