Open danjenkins opened 7 years ago
Are you talking about https://beaufortfrancois.github.io/sandbox/web-bluetooth/generator/?
Oh sorry, Yes - I see it as its own thing :D
I see why it is tempting to cache all of them. That's what I do at https://googlechrome.github.io/samples/web-bluetooth/read-characteristic-value-changed.html
However, I also like using getPrimaryService
and getCharacteristic
instead as I'm sure to always get "live" services/characteristics no matter what.
Hmmm, Just seems like a lot of code duplication and not ideal. By the time you add a couple more characteristics to the class, your class has a tonne of duplicate code. How would you feel about having a function that returned a promise and you'd pass the service and characteristic to the function - you'd then be able to reuse this for other characteristics (someone extending the class) and re-use it in the existing methods - meaning you could replace all of the getPrimaryService and getCharacteristic chained calls with this one function call?
Instead of accessing the same services and charcteristics over and over - put these references in the constructor and reference them there