Files
flipper/flipper-js-client-sdk
Rakha Kanz Kautsar 23afff9e2b flipper-js-client-sdk: fix undefined this on connectPlugin and disconnectPlugin (#1506)
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.

![image](https://user-images.githubusercontent.com/1536976/91691584-72b24c80-eb9a-11ea-88f1-984f2be8ab4a.png)

## 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
2020-09-02 07:21:26 -07:00
..
2020-06-11 08:45:35 -07:00
2020-06-11 08:45:35 -07:00

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'})