Skip to content

Commit c42a783

Browse files
authored
feat!(plugin): Remove SubscriptionCallback type (#259)
1 parent 4948edc commit c42a783

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

plugin/src/definitions.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface PortalsPlugin {
99
): Promise<void>;
1010
addListener<T = unknown>(
1111
eventName: string,
12-
listenerFunc: SubscriptionCallback<T>,
12+
listenerFunc: (result: PortalMessage<T>) => void,
1313
): Promise<PluginListenerHandle> & PluginListenerHandle;
1414
}
1515

@@ -31,11 +31,3 @@ export interface PortalMessage<TData = any> {
3131
topic: string;
3232
data?: TData;
3333
}
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;

plugin/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type {
55
InitialContext,
66
PortalMessage,
77
PortalsPlugin,
8-
SubscriptionCallback,
98
} from './definitions';
109

1110
const Portals = registerPlugin<PortalsPlugin>('Portals', {
@@ -20,17 +19,18 @@ const Portals = registerPlugin<PortalsPlugin>('Portals', {
2019
export function getInitialContext<T = unknown>():
2120
| InitialContext<T>
2221
| undefined {
23-
if (Capacitor.getPlatform() === "android") {
22+
if (Capacitor.getPlatform() === 'android') {
23+
// eslint-disable-next-line
2424
//@ts-ignore
25-
return JSON.parse(AndroidInitialContext.initialContext())
25+
return JSON.parse(AndroidInitialContext.initialContext());
2626
} else {
2727
return (window as any).portalInitialContext;
2828
}
2929
}
3030

3131
export function subscribe<T = unknown>(
3232
topic: string,
33-
callback: SubscriptionCallback<T>,
33+
callback: (result: PortalMessage<T>) => void,
3434
): Promise<PluginListenerHandle> {
3535
return Portals.addListener(topic, callback);
3636
}

plugin/src/web.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ import type { PortalMessage, PortalsPlugin } from './definitions';
44

55
export class PortalsWeb extends WebPlugin implements PortalsPlugin {
66
// eslint-disable-next-line
7-
async publishNative(_message: PortalMessage): Promise<void> { }
7+
async publishNative(_message: PortalMessage): Promise<void> {}
88
}

0 commit comments

Comments
 (0)