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.  ## 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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
787e578a33
commit
23afff9e2b
@@ -123,12 +123,12 @@ export abstract class FlipperClient {
|
||||
this._isConnected = true;
|
||||
Array.from(this.plugins.values())
|
||||
.filter((plugin) => plugin.runInBackground())
|
||||
.map(this.connectPlugin);
|
||||
.map(this.connectPlugin, this);
|
||||
}
|
||||
|
||||
onDisconnect() {
|
||||
this._isConnected = false;
|
||||
Array.from(this.plugins.values()).map(this.disconnectPlugin);
|
||||
Array.from(this.plugins.values()).map(this.disconnectPlugin, this);
|
||||
}
|
||||
|
||||
abstract start(appName: string): void;
|
||||
|
||||
Reference in New Issue
Block a user