FlipperBackgroundPlugin
Summary:
Adds a new type of plugin: `FlipperBackgroundPlugin`
Background plugins are not torn down when the user switches to another plugin so they keep receiving messages in the background.
Background plugins need to use persistedState to keep their data. To handle the messages received in the background they need to implement a static method that merges a message with the current state from redux. The plugin doesn't need to call this method itself, it is called from `client.js`.
```static persistedStateReducer = (
persistedState: PersistedState,
data: Object,
): PersistedState
```
This method is used to handle messages in both foreground and background.
Reviewed By: danielbuechele
Differential Revision: D10256305
fbshipit-source-id: d86da9caa1b75178841a9a347eb427112141eaa3
This commit is contained in:
committed by
Facebook Github Bot
parent
5bbfa58909
commit
ac7980993c
@@ -12,13 +12,8 @@ import type Logger from '../fb-stubs/Logger.js';
|
||||
import type Client from '../Client.js';
|
||||
|
||||
export default (store: Store, logger: Logger) => {
|
||||
const server = new Server(logger);
|
||||
store.subscribe(() => {
|
||||
let currentState = store.getState();
|
||||
currentState.connections.clients.forEach((client: Client) => {
|
||||
client.selectedPlugin = currentState.connections.selectedPlugin;
|
||||
});
|
||||
});
|
||||
const server = new Server(logger, store);
|
||||
|
||||
server.addListener('new-client', (client: Client) => {
|
||||
store.dispatch({
|
||||
type: 'NEW_CLIENT',
|
||||
|
||||
Reference in New Issue
Block a user