From f72e4b5122686b80322e6601c0003e0f436546b1 Mon Sep 17 00:00:00 2001 From: John Knox Date: Fri, 3 May 2019 07:07:40 -0700 Subject: [PATCH] Tidy up "Sending data to Plugins" page Summary: * Made the code snippets uniform across languages. * Renamed to "Providing data to plugins" because sending hints at sending across the desktop-client connection which is misleading. Reviewed By: danielbuechele Differential Revision: D15198081 fbshipit-source-id: e2c318cdc6055c191f47e846b518c26dd21e4a68 --- docs/extending/send-data.md | 16 ++++++---------- website/i18n/en.json | 4 ++-- 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/docs/extending/send-data.md b/docs/extending/send-data.md index d72a2e462..df097c9b9 100644 --- a/docs/extending/send-data.md +++ b/docs/extending/send-data.md @@ -1,21 +1,19 @@ --- id: send-data -title: Sending Data to Plugins +title: Providing data to plugins --- 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": +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); -// Client may be null if AndroidFlipperClient.createInstance() was never called -// which is the case in production builds. if (client != null) { final MyFlipperPlugin plugin = client.getPluginByClass(MyFlipperPlugin.class); plugin.sendData(myData); @@ -29,13 +27,11 @@ MyFlipperPlugin *myPlugin = [client pluginWithIdentifier:@"MyFlipperPlugin"]; ``` ```c++ -auto &client = FlipperClient::instance(); - -// "MyFlipperPlugin" is the return value of MyFlipperPlugin::identifier() +auto& client = FlipperClient::instance(); auto myPlugin = client.getPlugin("MyFlipperPlugin"); - -myPlugin->sendData(myData); -``` +if (myPlugin) { + myPlugin->sendData(myData); +} ``` diff --git a/website/i18n/en.json b/website/i18n/en.json index 92f51b328..9700bec83 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -38,7 +38,7 @@ "title": "JavaScript Plugin Definition" }, "extending/layout-inspector": { - "title": "Extending the Layout Inspector" + "title": "Extending Layout Inspector" }, "extending/new-clients": { "title": "Implementing a Flipper Client" @@ -47,7 +47,7 @@ "title": "Searching and Filtering" }, "extending/send-data": { - "title": "Sending Data to Plugins" + "title": "Providing data to plugins" }, "extending/styling-components": { "title": "Styling Components"