Add generics to server add-on connection
Reviewed By: mweststrate Differential Revision: D34307356 fbshipit-source-id: 27e61355a85995368ebb197c42d58f4145473567
This commit is contained in:
committed by
Facebook GitHub Bot
parent
673bb9135e
commit
01a5f3da90
@@ -23,9 +23,9 @@ export type ServerAddOnModuleToDesktopConnectionEvents = {
|
||||
|
||||
export class ServerAddOnModuleToDesktopConnection
|
||||
extends EventEmitter
|
||||
implements ServerAddOnPluginConnection
|
||||
implements ServerAddOnPluginConnection<any, any>
|
||||
{
|
||||
private subscriptions: Map<string, FlipperPluginReceiver> = new Map();
|
||||
private subscriptions: Map<string, FlipperPluginReceiver<any>> = new Map();
|
||||
|
||||
constructor(private readonly pluginName: string) {
|
||||
super();
|
||||
@@ -44,7 +44,7 @@ export class ServerAddOnModuleToDesktopConnection
|
||||
this.emit('message', message);
|
||||
}
|
||||
|
||||
receive(method: string, receiver: FlipperPluginReceiver) {
|
||||
receive(method: string, receiver: FlipperPluginReceiver<any>) {
|
||||
this.subscriptions.set(method, receiver);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,13 +7,12 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {ServerAddOnStartDetails} from 'flipper-common';
|
||||
import {ServerAddOnStartDetails, createControlledPromise} from 'flipper-common';
|
||||
import {loadServerAddOn} from '../loadServerAddOn';
|
||||
import {PluginManager} from '../PluginManager';
|
||||
import {ServerAddOnManager} from '../ServerAddManager';
|
||||
import {ServerAddOnModuleToDesktopConnection} from '../ServerAddOnModuleToDesktopConnection';
|
||||
import {
|
||||
createControlledPromise,
|
||||
detailsBundled,
|
||||
detailsInstalled,
|
||||
initialOwner,
|
||||
|
||||
@@ -7,12 +7,11 @@
|
||||
* @format
|
||||
*/
|
||||
|
||||
import {ServerAddOnStartDetails} from 'flipper-common';
|
||||
import {ServerAddOnStartDetails, createControlledPromise} from 'flipper-common';
|
||||
import {loadServerAddOn} from '../loadServerAddOn';
|
||||
import {ServerAddOn} from '../ServerAddOn';
|
||||
import {ServerAddOnModuleToDesktopConnection} from '../ServerAddOnModuleToDesktopConnection';
|
||||
import {
|
||||
createControlledPromise,
|
||||
detailsBundled,
|
||||
detailsInstalled,
|
||||
initialOwner,
|
||||
|
||||
@@ -17,17 +17,3 @@ export const detailsBundled: ServerAddOnStartDetails = {
|
||||
export const detailsInstalled: ServerAddOnStartDetails = {
|
||||
path: '/dagobar/',
|
||||
};
|
||||
|
||||
export const createControlledPromise = <T,>() => {
|
||||
let resolve!: (...res: T extends void ? [] : [T]) => void;
|
||||
let reject!: (reason: unknown) => void;
|
||||
const promise = new Promise<T>((resolveP, rejectP) => {
|
||||
resolve = resolveP as typeof resolve;
|
||||
reject = rejectP;
|
||||
});
|
||||
return {
|
||||
promise,
|
||||
resolve,
|
||||
reject,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -17,7 +17,7 @@ import {assertNotNull} from '../comms/Utilities';
|
||||
import defaultPlugins from '../defaultPlugins';
|
||||
|
||||
interface ServerAddOnModule {
|
||||
default: ServerAddOnFn;
|
||||
default: ServerAddOnFn<any, any>;
|
||||
}
|
||||
|
||||
export const loadServerAddOn = (
|
||||
|
||||
Reference in New Issue
Block a user