From 0ba08150f68519eaeca3509a8c4b6f3d6dc69f04 Mon Sep 17 00:00:00 2001 From: Michel Weststrate Date: Wed, 9 Jun 2021 07:25:19 -0700 Subject: [PATCH] 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 --- docs/extending/create-plugin.mdx | 7 +++++++ docs/extending/flipper-plugin.mdx | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/docs/extending/create-plugin.mdx b/docs/extending/create-plugin.mdx index 42d58b679..1bfa3d0e5 100644 --- a/docs/extending/create-plugin.mdx +++ b/docs/extending/create-plugin.mdx @@ -297,6 +297,13 @@ if (myPlugin) { 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 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. diff --git a/docs/extending/flipper-plugin.mdx b/docs/extending/flipper-plugin.mdx index 12e16757f..82bc2dfc6 100644 --- a/docs/extending/flipper-plugin.mdx +++ b/docs/extending/flipper-plugin.mdx @@ -99,6 +99,8 @@ export function plugin(client: PluginClient) { } ``` +The Flipper Sample application contains a plugin that demonstrates these API, see [bi-directional-communication-demo](create-plugin#bi-directional-communication-demo). + #### `onUnhandledMessage` 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` Usage: `client.addMenuEntry(...entry: MenuEntry[])`