Summary: Docusaurus 2 is quite a lot more powerful than docu 1 it turns out. This should convert the website fully. * [done] Go through migration guide https://v2.docusaurus.io/docs/migrating-from-v1-to-v2 * [done] Convert landing page html * [done] Convert all images to img tags * [done] Convert all .md files to .mdx * [done] Make sure ui-doc generation and including still works * [done] Scan every page visually for sanity check * [done] Make sure footer still works * [done] Make sure search still works * [done] Change all links/ to links/index * [done] Change all links.md to links * [done] Add some custom css to make the navbar look like the old one and darken the footer. Reviewed By: passy Differential Revision: D21158717 fbshipit-source-id: 5f45b711b1b6fd5ece4c5c15c55635c7ebbfb568
40 lines
1.4 KiB
Plaintext
40 lines
1.4 KiB
Plaintext
---
|
|
id: send-data
|
|
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". Note that null checks may be required as plugins may not be initialized, for example in production builds.
|
|
|
|
|
|
<!--DOCUSAURUS_CODE_TABS-->
|
|
<!--Android-->
|
|
```java
|
|
final FlipperClient client = AndroidFlipperClient.getInstance(context);
|
|
if (client != null) {
|
|
final MyFlipperPlugin plugin = client.getPluginByClass(MyFlipperPlugin.class);
|
|
plugin.sendData(myData);
|
|
}
|
|
```
|
|
<!--iOS-->
|
|
```objective-c
|
|
FlipperClient *client = [FlipperClient sharedClient];
|
|
MyFlipperPlugin *myPlugin = [client pluginWithIdentifier:@"MyFlipperPlugin"];
|
|
[myPlugin sendData:myData];
|
|
```
|
|
<!--C++-->
|
|
```c++
|
|
auto& client = FlipperClient::instance();
|
|
auto myPlugin = client.getPlugin<MyFlipperPlugin>("MyFlipperPlugin");
|
|
if (myPlugin) {
|
|
myPlugin->sendData(myData);
|
|
}
|
|
```
|
|
<!--END_DOCUSAURUS_CODE_TABS-->
|
|
|
|
|
|
Here, `sendData` is an example of a method that might be implemented by the Flipper plugin.
|