call notifications API

Summary:
Adding a static method plugins can implement to trigger notifications:

```
static getActiveNotifications: ?(persistedState: P) => Array<Notification>;
```

When the plugin's persisted state changes, this API is called from the `notification`-dispatcher which updates the notifications store.

Reviewed By: passy

Differential Revision: D10378434

fbshipit-source-id: 778fe3ad4229b03bd5ba14ebfdafa5020c25f34f
This commit is contained in:
Daniel Büchele
2018-10-18 02:45:28 -07:00
committed by Facebook Github Bot
parent ce996ba8af
commit 51f70fd78c
4 changed files with 47 additions and 40 deletions

View File

@@ -38,7 +38,6 @@ export type Props<T> = {
logger: Logger,
persistedState: T,
setPersistedState: (state: $Shape<T>) => void,
setActiveNotifications: (Array<Notification>) => void,
target: PluginTarget,
deepLinkPayload: ?string,
};
@@ -97,10 +96,6 @@ export class FlipperBasePlugin<
throw new TypeError(`Reducer ${actionData.type} isn't a function`);
}
}
componentDidUpdate(props: Props<*>, state: State): void {
props.setActiveNotifications(this.computeNotifications(props, state));
}
}
export class FlipperDevicePlugin<S = *, A = *, P = *> extends FlipperBasePlugin<
@@ -132,6 +127,7 @@ export class FlipperPlugin<S = *, A = *, P = *> extends FlipperBasePlugin<
P,
> {
static persistedStateReducer: ?(persistedState: P, data: Object) => $Shape<P>;
static getActiveNotifications: ?(persistedState: P) => Array<Notification>;
constructor(props: Props<*>) {
super(props);