diff --git a/docs/extending/create-plugin.mdx b/docs/extending/create-plugin.mdx index 446b96200..478b655f4 100644 --- a/docs/extending/create-plugin.mdx +++ b/docs/extending/create-plugin.mdx @@ -236,6 +236,50 @@ addPlugin({ +### Using the FlipperClient singleton to send data + +It is often useful to get an instance of a Flipper plugin to send data to it. Flipper makes this simple with built-in support. + +Plugins should be treated as singleton instances as there can only be one `FlipperClient` and each `FlipperClient` can only have one instance of a certain plugin. The Flipper API makes this simple by offering a way to get the current client and query it for plugins. + +Plugins are identified by the string that their identifier method returns, in this example, "MyFlipperPlugin". Note that null checks may be required as plugins may not be initialized, for example in production builds. + + + + +```java +final FlipperClient client = AndroidFlipperClient.getInstance(context); +if (client != null) { + final MyFlipperPlugin plugin = client.getPluginByClass(MyFlipperPlugin.class); + plugin.sendData(myData); +} +``` + + + + +```objective-c +FlipperClient *client = [FlipperClient sharedClient]; +MyFlipperPlugin *myPlugin = [client pluginWithIdentifier:@"MyFlipperPlugin"]; +[myPlugin sendData:myData]; +``` + + + + +```cpp +auto& client = FlipperClient::instance(); +auto myPlugin = client.getPlugin("MyFlipperPlugin"); +if (myPlugin) { + myPlugin->sendData(myData); +} +``` + + + + +Here, `sendData` is an example of a method that might be implemented by the Flipper plugin. + ## 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/send-data.mdx b/docs/extending/send-data.mdx index 145e55a98..270e49482 100644 --- a/docs/extending/send-data.mdx +++ b/docs/extending/send-data.mdx @@ -3,47 +3,6 @@ id: send-data title: Providing Data to Plugins --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import {Redirect} from '@docusaurus/router'; -It is often useful to get an instance of a Flipper plugin to send data to it. Flipper makes this simple with built-in support. - -Plugins should be treated as singleton instances as there can only be one `FlipperClient` and each `FlipperClient` can only have one instance of a certain plugin. The Flipper API makes this simple by offering a way to get the current client and query it for plugins. - -Plugins are identified by the string that their identifier method returns, in this example, "MyFlipperPlugin". Note that null checks may be required as plugins may not be initialized, for example in production builds. - - - - -```java -final FlipperClient client = AndroidFlipperClient.getInstance(context); -if (client != null) { - final MyFlipperPlugin plugin = client.getPluginByClass(MyFlipperPlugin.class); - plugin.sendData(myData); -} -``` - - - - -```objective-c -FlipperClient *client = [FlipperClient sharedClient]; -MyFlipperPlugin *myPlugin = [client pluginWithIdentifier:@"MyFlipperPlugin"]; -[myPlugin sendData:myData]; -``` - - - - -```cpp -auto& client = FlipperClient::instance(); -auto myPlugin = client.getPlugin("MyFlipperPlugin"); -if (myPlugin) { - myPlugin->sendData(myData); -} -``` - - - - -Here, `sendData` is an example of a method that might be implemented by the Flipper plugin. + diff --git a/website/sidebars.js b/website/sidebars.js index 70390716b..b23a6cf94 100644 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -96,7 +96,6 @@ module.exports = { ], 'Client plugin APIs': [ 'extending/create-plugin', - 'extending/send-data', 'extending/error-handling', 'extending/testing', 'extending/arch',