Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Companion loading when settings change

I noticed that when a setting in the settings component (index.jsx) changes the companion is loaded, but only with the file that contains 'me.launchReasons.settingsChanged' as entry point and all imports are ignored.
Is this the normal behaviour?

The only thing I can find about this in the documentation suggests that the companion should be loaded normally:

If the user changes application settings whilst the companion is not currently running, the companion will be automatically launched and the launchReason will be set to settingsChanged.
https://dev.fitbit.com/build/guides/settings/#settings-changed-launch-reason

 

Best Answer
0 Votes
3 REPLIES 3

I just discovered that if I move the code that uses me.launchReasons.settingsChanged to index.js the companion loads as expected. Previously I did not place 'import { me } from "companion";' and use 'me.launchReasons.settingsChanged' in the companion index.js but in an other file that is imported by index.js.


This behaviour still seems very strange to me though.

Best Answer
0 Votes

Hey Tjeerd,

 

I'm not sure how your companion is structured, but during the build process all of the companion javascript is bundled together, anything which is unreferenced is remove automatically though a process called "tree shaking".

 

You can check the generated output by downloading the .fba file, unzipping it, and looking in companion.zip

Best Answer
0 Votes

All my code is in the .fba file. But in the case where I used me.launchReasons.settingsChanged in an other file than index.js the code from files that were imported earlier than this file was simply not executed.

Best Answer
0 Votes