Support supportsMethod in FlipperPlugin
Summary: `supportsMethod` wasn't implemented in the new sandy APIs so far, but is needed for D24108772 Reviewed By: cekkaewnumchai Differential Revision: D24109496 fbshipit-source-id: 694344b423c1805baa193e4f2e1ad5f28483378b
This commit is contained in:
committed by
Facebook GitHub Bot
parent
e40eb2dadd
commit
7b758d2697
@@ -59,6 +59,11 @@ export interface PluginClient<
|
||||
method: Method,
|
||||
params: Parameters<Methods[Method]>[0],
|
||||
): ReturnType<Methods[Method]>;
|
||||
|
||||
/**
|
||||
* Checks if a method is available on the client implementation
|
||||
*/
|
||||
supportsMethod(method: keyof Methods): Promise<boolean>;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +80,7 @@ export interface RealFlipperClient {
|
||||
fromPlugin: boolean,
|
||||
params?: Object,
|
||||
): Promise<Object>;
|
||||
supportsMethod(api: string, method: string): Promise<boolean>;
|
||||
}
|
||||
|
||||
export type PluginFactory<
|
||||
@@ -125,6 +131,13 @@ export class SandyPluginInstance extends BasePluginInstance {
|
||||
onMessage: (event, callback) => {
|
||||
this.events.on('event-' + event, callback);
|
||||
},
|
||||
supportsMethod: async (method) => {
|
||||
this.assertConnected();
|
||||
return await realClient.supportsMethod(
|
||||
this.definition.id,
|
||||
method as any,
|
||||
);
|
||||
},
|
||||
};
|
||||
this.initializePlugin(() =>
|
||||
definition.asPluginModule().plugin(this.client),
|
||||
|
||||
Reference in New Issue
Block a user