espruino / BangleApps

Bangle.js App Loader (and Apps)
https://banglejs.com/apps
MIT License
495 stars 1.17k forks source link

[wear_detect] Do isWorn need to be Promise ? #2150

Closed Stiralbios closed 2 years ago

Stiralbios commented 2 years ago

I wanted to use the isWorn function in the new wear_detect module. However it would add complexity to the code I want to use it on because it is a Promise. Does it need to be Promise ?

gfwilliams commented 2 years ago

Yes - because in future it's extremely possible that someone will need to make it use a sensor that doesn't return data immediately.

For example the sensible thing would be to make it use the isWorn field returned by the heart rate monitor, but it wouldn't be able to do that if it wasn't a promise