Add computeNotifications method to FlipperBasePlugin

Summary:
Method `computeNotifications` added to the base plugin class.
Plugins should implement this to define a mapping from their state+props to the notifications they are emitting.

I've plugged this into componentDidUpdate, because we don't yet have the background plugin infra. When we do, we'll want some other incoming data hook to use so it's not tied to the react component rendering.

Example usage added to network plugin in the next commit.

Reviewed By: passy

Differential Revision: D10127875

fbshipit-source-id: efd4d8cfc0d3d33852a6cf9a290549a5f90d389d
This commit is contained in:
John Knox
2018-10-09 08:22:22 -07:00
committed by Facebook Github Bot
parent 1a5b127d58
commit 6df906ed5f
4 changed files with 148 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import {combineReducers} from 'redux';
import application from './application.js';
import connections from './connections.js';
import pluginStates from './pluginStates.js';
import notifications from './notifications.js';
import type {
State as ApplicationState,
@@ -22,6 +23,10 @@ import type {
State as PluginsState,
Action as PluginsAction,
} from './pluginStates.js';
import type {
State as NotificationsState,
Action as NotificationsAction,
} from './notifications.js';
import type {Store as ReduxStore} from 'redux';
export type Store = ReduxStore<
@@ -29,12 +34,18 @@ export type Store = ReduxStore<
application: ApplicationState,
connections: DevicesState,
pluginStates: PluginsState,
notifications: NotificationsState,
},
ApplicationAction | DevicesAction | PluginsAction | {|type: 'INIT'|},
| ApplicationAction
| DevicesAction
| PluginsAction
| NotificationsAction
| {|type: 'INIT'|},
>;
export default combineReducers({
application,
connections,
pluginStates,
notifications,
});