From da5856138ddd25e8f56db8a3fac6fb975c990cb1 Mon Sep 17 00:00:00 2001 From: Andrey Goncharov Date: Wed, 8 Nov 2023 02:08:25 -0800 Subject: [PATCH] Add event emitter to datasource Reviewed By: LukeDefeo Differential Revision: D51026560 fbshipit-source-id: 8348c6765633d7eecf0d1c80bc5bbd5af8130298 --- desktop/flipper-plugin-core/src/data-source/DataSource.tsx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/desktop/flipper-plugin-core/src/data-source/DataSource.tsx b/desktop/flipper-plugin-core/src/data-source/DataSource.tsx index 75444ea62..3dd7e94bb 100644 --- a/desktop/flipper-plugin-core/src/data-source/DataSource.tsx +++ b/desktop/flipper-plugin-core/src/data-source/DataSource.tsx @@ -11,6 +11,7 @@ import sortedIndexBy from 'lodash/sortedIndexBy'; import sortedLastIndexBy from 'lodash/sortedLastIndexBy'; import property from 'lodash/property'; import lodashSort from 'lodash/sortBy'; +import EventEmitter from 'eventemitter3'; // If the dataSource becomes to large, after how many records will we start to drop items? const dropFactor = 0.1; @@ -180,6 +181,8 @@ export class DataSource { [viewId: string]: DataSourceView; }; + public readonly outputEventEmitter = new EventEmitter(); + constructor( keyAttribute: keyof T | undefined, secondaryIndices: IndexDefinition[] = [], @@ -550,6 +553,7 @@ export class DataSource { Object.entries(this.additionalViews).forEach(([, dataView]) => { dataView.processEvent(event); }); + this.outputEventEmitter.emit(event.type, event); } private storeSecondaryIndices(value: T) {