airbnb / mavericks

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

Question - collectAsStateWithLifecycle #711

Open JuxBzh opened 7 months ago

JuxBzh commented 7 months ago

This article from Manuel Vivo suggests to use collectAsStateWithLifecycle API instead of standard collectAsState to safely consume flows in Jetpack Compose. I noticed that extension provided in mvrx-compose module rely on collectAsState. Is it planned to use to collectAsStateWithLifecyle or is there a specific feature in Mavericks implementation that makes it already Lifecycle aware ?

Regards.

elihart commented 7 months ago

I don't think modifying the existing collectAsState functions would be good, as it might not be what some people want, but we could add equivalent methods for collectAsStateWithLifecyle in https://github.com/airbnb/mavericks/blob/main/mvrx-compose/src/main/kotlin/com/airbnb/mvrx/compose/MavericksComposeExtensions.kt

Feel free to put up a PR

JuxBzh commented 6 months ago

Hi @elihart. I'm trying to put up a PR but I constantly get rejected when trying to push my branch event if I created the proper Personal Access Token. Is there something more I need to do ?

elihart commented 6 months ago

The way github works, you need to fork the project and push the branch to your fork, then create a PR from there

JuxBzh commented 6 months ago

Thanks for the advice. Here is the PR -> https://github.com/airbnb/mavericks/pull/714