diff --git a/src/Client.js b/src/Client.js index f5b935fdd..71081191d 100644 --- a/src/Client.js +++ b/src/Client.js @@ -469,4 +469,13 @@ export default class Client extends EventEmitter { } return this.rawSend('execute', {api, method, params}); } + + supportsMethod(api: string, method: string): Promise { + if (this.sdkVersion < 2) { + return Promise.resolve(false); + } + return this.rawCall('isMethodSupported', {api, method}).then( + response => response.isSupported, + ); + } } diff --git a/src/plugin.js b/src/plugin.js index b19520264..5e9978da4 100644 --- a/src/plugin.js +++ b/src/plugin.js @@ -23,6 +23,7 @@ export type PluginClient = {| send: (method: string, params?: Object) => void, call: (method: string, params?: Object) => Promise, subscribe: (method: string, callback: (params: any) => void) => void, + supportsMethod: (method: string) => Promise, |}; type PluginTarget = BaseDevice | Client; @@ -168,6 +169,7 @@ export class FlipperPlugin extends FlipperBasePlugin< }); this.realClient.subscribe(id, method, callback); }, + supportsMethod: method => this.realClient.supportsMethod(id, method), }; }