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:
Michel Weststrate
2020-10-05 13:32:03 -07:00
committed by Facebook GitHub Bot
parent e40eb2dadd
commit 7b758d2697
3 changed files with 61 additions and 0 deletions

View File

@@ -43,6 +43,8 @@ interface StartPluginOptions {
initialState?: Record<string, any>;
isArchived?: boolean;
isBackgroundPlugin?: boolean;
/** Provide a set of unsupported methods to simulate older clients that don't support certain methods yet */
unsupportedMethods?: string[];
}
type ExtractClientType<Module extends FlipperPluginModule<any>> = Parameters<
@@ -195,6 +197,9 @@ export function startPlugin<Module extends FlipperPluginModule<any>>(
): Promise<Object> {
return sendStub(method, params);
},
async supportsMethod(_api: string, method: string) {
return !options?.unsupportedMethods?.includes(method);
},
};
const pluginInstance = new SandyPluginInstance(