Skip to content
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

Refactor: Use static Lazy instance for all sensors #19278

Conversation

nickodei
Copy link
Contributor

@nickodei nickodei commented Jan 19, 2025

GitHub Issue (If applicable): closes #19274

PR Type

What kind of change does this PR introduce?

  • Refactoring (no functional changes, no api changes)

What is the current behavior?

Most sensor classes use a static instance and track with an boolean if the instance is already created. This caused code duplication and wasn't implemented like the LightSensor.cs implementation.

What is the new behavior?

Use a static Lazy instance for instance creation, which removes the object lock, as well as the boolean. This follows the implementation already in LightSensor.cs.

PR Checklist

Please check if your PR fulfills the following requirements:

Other information

Internal Issue (If applicable):

@github-actions github-actions bot added platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform labels Jan 19, 2025
@unodevops
Copy link
Contributor

🤖 Your Docs stage site is ready! Visit it here: https://unodocsprstaging.z13.web.core.windows.net/pr-19278/index.html

@unodevops
Copy link
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here: https://unowasmprstaging.z20.web.core.windows.net/pr-19278/index.html

@nickodei
Copy link
Contributor Author

I tested my changes on the SampleApp for Android with the Android-Emulator mainly by going to the Windows.Devices pages and trying out the sensor events. This all seemed fine to me and changes where registered correctly

@nickodei nickodei changed the title refactor: Use static Lazy instance for all sensors Refactor: Use static Lazy instance for all sensors Jan 22, 2025
Copy link
Member

@MartinZikmund MartinZikmund left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🚀

Thanks for the nice PR @nickodei!

@MartinZikmund MartinZikmund merged commit 7f57344 into unoplatform:master Jan 22, 2025
115 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
platform/android 🤖 Categorizes an issue or PR as relevant to the Android platform platform/ios 🍎 Categorizes an issue or PR as relevant to the iOS platform platform/wasm 🌐 Categorizes an issue or PR as relevant to the WebAssembly platform
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use Lazy for instance creation on sensor classes
3 participants