-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Save references to services and characteristics, same as device #12
Comments
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 |
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
The text was updated successfully, but these errors were encountered: