12-24-2017 16:08
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
12-24-2017 16:08
This is probably a dumb question, but is there an elegant way to call a function in companion/index.js in response to an event (eg, button onclick) in settings/index.jsx? I can get the companion to respond to changes in settings, but I'd like to be able to get the companion to respond to event handlers.
01-07-2018 08:27 - edited 01-07-2018 08:27
01-07-2018 08:27 - edited 01-07-2018 08:27
Did you figure this out? I am trying to do this as well.
Best Answer01-07-2018 11:29
Gold Fitbit Product Experts share support knowledge on the forums and advocate for the betterment of Fitbit products and services. Learn more
01-07-2018 11:29
Not exactly, but I came up with a kludge that seems to work. In index.jsx:
<Button
label="Create/Update"
onClick={() => {
props.settingsStorage.setItem('createAccount', 'true');
}}
/>In companion/index.js:
if (me.launchReasons.settingsChanged) {
let createAccountSetting = settingsStorage.getItem('createAccount');
if (createAccountSetting === 'true') createAccount();
}
settingsStorage.onchange = function(evt) {
if (evt.key === "createAccount" && evt.newValue === "true") createAccount();
}
Best Answer