google / jetpack-camera-app

Apache License 2.0
152 stars 29 forks source link

Refactor ScreenFlash UI state #164

Open dturner opened 8 months ago

dturner commented 8 months ago

What I have done and why

Zeronfinity commented 7 months ago

It seems like CameraXCameraUseCase has the same problem then? Should we refactor there as well?

temcguir commented 7 months ago

It seems like CameraXCameraUseCase has the same problem then? Should we refactor there as well?

It looks like the CoroutineScope in CameraXCameraUseCase is used only to emit screen flash events into theMutableSharedFlow. Since we're already converting this to a StateFlow in ScreenFlash.kt, we could just use a StateFlow in CameraUseCase and avoid needing to launch into the CoroutineScope. We can then remove it from the CameraXCameraUseCase constructor.