airbnb / mavericks

Mavericks: Android on Autopilot
https://airbnb.io/mavericks/
Apache License 2.0
5.85k stars 498 forks source link

how to use stateflow in MavericksViewModel #682

Closed unhoo28 closed 1 year ago

unhoo28 commented 1 year ago

Hello, i have a question. I need to observe the flow from room, but with execute looks like only receive onece, and the room chage later will not be receive in viewmodel. how can I observe the room flow continuously in viewmodel?

vulpeszerda commented 1 year ago

https://github.com/airbnb/mavericks/blob/5174519c59a52e8df3a49b213d582dc4aba37bb2/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModel.kt#L167-L175

use above.

It is implemented internally with below https://github.com/airbnb/mavericks/blob/5174519c59a52e8df3a49b213d582dc4aba37bb2/mvrx-common/src/main/java/com/airbnb/mvrx/MavericksRepository.kt#L235-L253

unhoo28 commented 1 year ago

https://github.com/airbnb/mavericks/blob/5174519c59a52e8df3a49b213d582dc4aba37bb2/mvrx/src/main/kotlin/com/airbnb/mvrx/MavericksViewModel.kt#L167-L175

use above.

It is implemented internally with below

https://github.com/airbnb/mavericks/blob/5174519c59a52e8df3a49b213d582dc4aba37bb2/mvrx-common/src/main/java/com/airbnb/mvrx/MavericksRepository.kt#L235-L253

Thank you, it works fine~