From a276af9c1fa976e4ae8d3fc0a1293932630999ae Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 2 May 2019 12:34:15 -0700 Subject: [PATCH] Show communcating with devices page Summary: This page got lost in the reorganisation. Adding it back. There's still work to be done on the content and organisation of these docs. Reviewed By: passy Differential Revision: D15184349 fbshipit-source-id: 76256ba53189579bec363903dc4068a421cafc98 --- docs/{ => extending}/communicating.md | 10 +++------- website/i18n/en.json | 8 ++++---- 2 files changed, 7 insertions(+), 11 deletions(-) rename docs/{ => extending}/communicating.md (70%) diff --git a/docs/communicating.md b/docs/extending/communicating.md similarity index 70% rename from docs/communicating.md rename to docs/extending/communicating.md index 06c478a06..621e25c73 100644 --- a/docs/communicating.md +++ b/docs/extending/communicating.md @@ -24,20 +24,16 @@ There are three main ways your desktop plugin can communicate with connected dev With remote method calls your plugin can call a method on the attached client. This is useful for querying information from the client that your plugin wants to display. The first parameter is the name of the client API and the second is the specific method on that API. Optionally a JSON object can be passed as an argument to the client. ```javascript -this.client.call('methodName', DATA).then(res => { +this.client.call('methodName', data).then(res => { // res contains client response }); ``` -This function returns a promise so that you can await a potential response from the client. If you are calling a method on the client but don't expect a response then you should instead opt for using the `send()` function. - -```javascript -this.client.send('methodName', DATA); -``` +This function returns a promise so that you can await a potential response from the client. This also gives you the opportunity to handle or report errors encountered by the client using `Promise.catch`. ## Subscriptions -A client is not only able to respond to method calls but also push data directly to the Flipper desktop app. With the subscribe API your plugin can subscribe to there pushes from the client. Pass the name of the method and the API it is part of as well as a callback function to start a subscription. Any time the client sends a push matching this method the callback will be called with any attached data as a javascript object. +A client is not only able to respond to method calls but also push data directly to the Flipper desktop app. With the subscribe API your plugin can subscribe to data pushed from the client. Pass the name of the method and the API it is part of as well as a callback function to start a subscription. Any time the client sends a push matching this method the callback will be called with any attached data as a javascript object. ```javascript this.client.subscribe('methodName', data => { diff --git a/website/i18n/en.json b/website/i18n/en.json index c2db0a894..5702ce380 100644 --- a/website/i18n/en.json +++ b/website/i18n/en.json @@ -5,10 +5,6 @@ "previous": "Previous", "tagline": "Extensible mobile app debugging", "docs": { - "communicating": { - "title": "Device Communication", - "sidebar_label": "Device Communication" - }, "custom-ports": { "title": "Running Flipper with different ports", "sidebar_label": "Using different ports" @@ -16,6 +12,10 @@ "extending/arch": { "title": "Architecture" }, + "extending/communicating": { + "title": "Device Communication", + "sidebar_label": "Device Communication" + }, "extending/create-plugin": { "title": "Mobile Setup" },