Add isMethodSupported to client

Summary: Allows plugins to check if extension commands or new features are enabled in the current app, by calling `this.client.supportsMethod('xxx')`.

Reviewed By: passy

Differential Revision: D14225961

fbshipit-source-id: c9f7f5b3091209f0ce9705d9d3a0ec173edf3e25
This commit is contained in:
John Knox
2019-02-27 10:07:02 -08:00
committed by Facebook Github Bot
parent 6dc2215753
commit 0445a05e5b
2 changed files with 11 additions and 0 deletions

View File

@@ -469,4 +469,13 @@ export default class Client extends EventEmitter {
}
return this.rawSend('execute', {api, method, params});
}
supportsMethod(api: string, method: string): Promise<boolean> {
if (this.sdkVersion < 2) {
return Promise.resolve(false);
}
return this.rawCall('isMethodSupported', {api, method}).then(
response => response.isSupported,
);
}
}