Update send-data Flipper references
Summary: Sonar -> Flipper Reviewed By: danielbuechele Differential Revision: D10114910 fbshipit-source-id: 28f5d6ac7a71ae645872adda820feea6adb21f73
This commit is contained in:
committed by
Facebook Github Bot
parent
3e971775c3
commit
184d952a61
@@ -6,18 +6,18 @@ sidebar_label: 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.
|
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 `SonarClient` and each `SonarClient` 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 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, "MySonarPlugin":
|
Plugins are identified by the string that their identifier method returns, in this example, "MyFlipperPlugin":
|
||||||
|
|
||||||
### Android
|
### Android
|
||||||
|
|
||||||
```java
|
```java
|
||||||
final SonarClient client = AndroidFlipperClient.getInstance(context);
|
final FlipperClient client = AndroidFlipperClient.getInstance(context);
|
||||||
// Client may be null if AndroidFlipperClient.createInstance() was never called
|
// Client may be null if AndroidFlipperClient.createInstance() was never called
|
||||||
// which is the case in production builds.
|
// which is the case in production builds.
|
||||||
if (client != null) {
|
if (client != null) {
|
||||||
final MySonarPlugin plugin = client.getPlugin("MySonarPlugin");
|
final MyFlipperPlugin plugin = client.getPlugin("MyFlipperPlugin");
|
||||||
plugin.sendData(myData);
|
plugin.sendData(myData);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
@@ -33,16 +33,16 @@ MyFlipperPlugin *myPlugin = [client pluginWithIdentifier:@"MyFlipperPlugin"];
|
|||||||
### C++
|
### C++
|
||||||
|
|
||||||
```c++
|
```c++
|
||||||
auto &client = SonarClient::instance();
|
auto &client = FlipperClient::instance();
|
||||||
|
|
||||||
// "MySonarPlugin is the return value of MySonarPlugin::identifier()
|
// "MyFlipperPlugin is the return value of MyFlipperPlugin::identifier()
|
||||||
auto aPlugin = client.getPlugin("MySonarPlugin");
|
auto aPlugin = client.getPlugin("MyFlipperPlugin");
|
||||||
|
|
||||||
// aPlugin is a std::shared_ptr<SonarPlugin>. Downcast to expected type.
|
// aPlugin is a std::shared_ptr<FlipperPlugin>. Downcast to expected type.
|
||||||
auto myPlugin = std::static_pointer_cast<MySonarPlugin>(aPlugin);
|
auto myPlugin = std::static_pointer_cast<MyFlipperPlugin>(aPlugin);
|
||||||
|
|
||||||
// Alternatively, use the templated version
|
// Alternatively, use the templated version
|
||||||
myPlugin = client.getPlugin<MySonarPlugin>("MySonarPlugin");
|
myPlugin = client.getPlugin<MyFlipperPlugin>("MyFlipperPlugin");
|
||||||
|
|
||||||
myPlugin->sendData(myData);
|
myPlugin->sendData(myData);
|
||||||
```
|
```
|
||||||
|
|||||||
Reference in New Issue
Block a user