From d6bb5e5d32d19428f41a616a9e43dafc41ae23a2 Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Wed, 19 Jun 2019 03:41:57 -0700 Subject: [PATCH] Allow both subscriptions and persistedStateReducer Summary: The previous setup would first check for the presence of a `persistedStateReducer` and then skip the standard subscriptions if this was found. This is a bit of a foot gun because simply by introducing a new function, you'd silently lose your existing subscriptions. There are still some good reasons to support both as some subscriptions may not require persisting as they're directly tied to the state in the app at a given point. Reviewed By: danielbuechele Differential Revision: D15856372 fbshipit-source-id: a36bf40b1ceac431964610571eb70fff687b7607 --- src/Client.js | 23 ++++++++++------------- src/plugins/fresco/index.js | 1 + 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/Client.js b/src/Client.js index 5dac29720..997c95f58 100644 --- a/src/Client.js +++ b/src/Client.js @@ -294,23 +294,20 @@ export default class Client extends EventEmitter { }), ); } - } else { - const apiCallbacks = this.broadcastCallbacks.get(params.api); - if (!apiCallbacks) { - return; - } + } + const apiCallbacks = this.broadcastCallbacks.get(params.api); + if (!apiCallbacks) { + return; + } - const methodCallbacks: ?Set = apiCallbacks.get( - params.method, - ); - if (methodCallbacks) { - for (const callback of methodCallbacks) { - callback(params.params); - } + const methodCallbacks: ?Set = apiCallbacks.get(params.method); + if (methodCallbacks) { + for (const callback of methodCallbacks) { + callback(params.params); } } } - return; + return; // method === 'execute' } if (this.sdkVersion < 1) { diff --git a/src/plugins/fresco/index.js b/src/plugins/fresco/index.js index 4f15cd5f4..a2527892f 100644 --- a/src/plugins/fresco/index.js +++ b/src/plugins/fresco/index.js @@ -271,6 +271,7 @@ export default class extends FlipperPlugin { debugLog('init()'); this.updateCaches('init'); this.client.subscribe('events', (event: ImageEvent) => { + debugLog('Received events', event); const {surfaceList} = this.props.persistedState; const {attribution} = event; if (attribution instanceof Array && attribution.length > 0) {