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
@@ -8,6 +8,7 @@
|
||||
import type {SecureServerConfig} from './utils/CertificateProvider';
|
||||
import type Logger from './fb-stubs/Logger';
|
||||
import type {ClientQuery} from './Client.js';
|
||||
import type {Store} from './reducers/index.js';
|
||||
|
||||
import CertificateProvider from './utils/CertificateProvider';
|
||||
import {RSocketServer, ReactiveSocket} from 'rsocket-core';
|
||||
@@ -42,13 +43,15 @@ export default class Server extends EventEmitter {
|
||||
certificateProvider: CertificateProvider;
|
||||
connectionTracker: ConnectionTracker;
|
||||
logger: Logger;
|
||||
store: Store;
|
||||
|
||||
constructor(logger: Logger) {
|
||||
constructor(logger: Logger, store: Store) {
|
||||
super();
|
||||
this.logger = logger;
|
||||
this.connections = new Map();
|
||||
this.certificateProvider = new CertificateProvider(this, logger);
|
||||
this.connectionTracker = new ConnectionTracker(logger);
|
||||
this.store = store;
|
||||
this.init();
|
||||
}
|
||||
|
||||
@@ -244,7 +247,7 @@ export default class Server extends EventEmitter {
|
||||
const id = `${query.app}-${query.os}-${query.device}-${query.device_id}`;
|
||||
console.debug(`Device connected: ${id}`, 'server');
|
||||
|
||||
const client = new Client(id, query, conn, this.logger);
|
||||
const client = new Client(id, query, conn, this.logger, this.store);
|
||||
|
||||
const info = {
|
||||
client,
|
||||
|
||||
Reference in New Issue
Block a user