Document example plugin to demo bidi communcation

Summary: per title. As follow up for previous diff

Reviewed By: fabiomassimo

Differential Revision: D28965865

fbshipit-source-id: 440c8143ac44011d895b3f194cabe7c69c51af72
This commit is contained in:
Michel Weststrate
2021-06-09 07:25:19 -07:00
committed by Facebook GitHub Bot
parent 4fd8e0b8ca
commit 0ba08150f6
2 changed files with 11 additions and 0 deletions

View File

@@ -297,6 +297,13 @@ if (myPlugin) {
Here, `sendData` is an example of a method that might be implemented by the Flipper plugin. Here, `sendData` is an example of a method that might be implemented by the Flipper plugin.
### Bi-directional communication demo
An minimal communication demo can be found in our [Sample project]:
* [Desktop implementation](https://github.com/facebook/flipper/blob/master/desktop/plugins/public/example/index.tsx)
* [Android implementation](https://github.com/facebook/flipper/blob/master/android/sample/src/debug/java/com/facebook/flipper/plugins/example/ExampleFlipperPlugin.java) / [iOS implementation](https://github.com/facebook/flipper/tree/7bd4f80c2570bebb52af3cf49e45fc6130d6a473/iOS/Plugins/FlipperKitExamplePlugin/FlipperKitExamplePlugin)
## Background Plugins ## Background Plugins
In some cases you may want to provide data to Flipper even when your plugin is not currently active. Returning true in `runInBackground()` will result in `onConnect` being called as soon as Flipper connects, and allow you to use the connection at any time. See the [Client Plugin Lifecycle](client-plugin-lifecycle) for more details. In some cases you may want to provide data to Flipper even when your plugin is not currently active. Returning true in `runInBackground()` will result in `onConnect` being called as soon as Flipper connects, and allow you to use the connection at any time. See the [Client Plugin Lifecycle](client-plugin-lifecycle) for more details.

View File

@@ -99,6 +99,8 @@ export function plugin(client: PluginClient<Events, {}>) {
} }
``` ```
The Flipper Sample application contains a plugin that demonstrates these API, see [bi-directional-communication-demo](create-plugin#bi-directional-communication-demo).
#### `onUnhandledMessage` #### `onUnhandledMessage`
Usage: `client.onUnhandledMessage(callback: (event: string, params) => void)` Usage: `client.onUnhandledMessage(callback: (event: string, params) => void)`
@@ -235,6 +237,8 @@ export function plugin(client: PluginClient<{}, Methods>) {
} }
``` ```
The Flipper Sample application contains a plugin that demonstrates these API, see [bi-directional-communication-demo](create-plugin#bi-directional-communication-demo).
#### `addMenuEntry` #### `addMenuEntry`
Usage: `client.addMenuEntry(...entry: MenuEntry[])` Usage: `client.addMenuEntry(...entry: MenuEntry[])`