From 7cf216f114afd8d057942e7703fe34b87da9010d Mon Sep 17 00:00:00 2001 From: David Rowe Date: Wed, 18 Dec 2019 07:15:34 +1300 Subject: [PATCH] Add warning about EventBridge not immediately availble in TabletProxy --- libraries/ui/src/ui/TabletScriptingInterface.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libraries/ui/src/ui/TabletScriptingInterface.h b/libraries/ui/src/ui/TabletScriptingInterface.h index 04222b3ea1..3f834cab40 100644 --- a/libraries/ui/src/ui/TabletScriptingInterface.h +++ b/libraries/ui/src/ui/TabletScriptingInterface.h @@ -422,6 +422,12 @@ public: *
EventBridge.scriptEventReceived.connect(function(message) {
      *     ...
      * });
+ *

Warning: The EventBridge object is not necessarily set up immediately ready for the web + * page's script to use. A simple workaround that normally works is to add a delay before calling + * EventBridge.scriptEventReceived.connect(...). A better solution is to periodically call + * EventBridge.scriptEventReceived.connect(...) and then EventBridge.emitWebEvent(...) to send a + * message to the Interface script, and have that send a message back using emitScriptEvent(...); when the + * return message is received, the EventBridge is ready for use.

* @function TabletProxy#emitScriptEvent * @param {string|object} message - The message to send to the web page. */