Summary: `this` is not defined for `connectPlugin` and `disconnectPlugin` because `Array.prototype.map` [replace `this` to `undefined` if not specified](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map): > If a thisArg parameter is provided, it will be used as callback's this value. Otherwise, the value undefined will be used as its this value. The this value ultimately observable by callback is determined according to the usual rules for determining the this seen by a function.  ## Changelog flipper-js-client-sdk: Fix undefined this due to array map Pull Request resolved: https://github.com/facebook/flipper/pull/1506 Test Plan: Tried creating custom client and connecting to websocket server Reviewed By: mweststrate Differential Revision: D23473033 Pulled By: nikoant fbshipit-source-id: bbfd9117da8aa8c7b491e219f98d17ccea48c0fd
flipper-sdk-api
SDK to build Flipper clients for JS based apps
Installation
yarn add flipper-client-sdk
Usage
Example
class SeaMammalPlugin extends AbsctractFlipperPlugin {
getId(): string {
return 'sea-mammals';
}
runInBackground(): boolean {
return true;
}
newRow(row: {id: string, url: string, title: string}) {
this.connection?.send("newRow", row)
}
}
const flipperClient = newWebviewClient();
cosnt plugin = new SeaMammalPlugin();
flipperClient.addPlugin();
flipperClient.start('Example JS App');
plugin.newRow({id: '1', title: 'Dolphin', url: 'example.com'})