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

Relationship between molecule and Compose UI #172

Open
eygraber opened this issue Jan 30, 2023 · 4 comments
Open

Relationship between molecule and Compose UI #172

eygraber opened this issue Jan 30, 2023 · 4 comments

Comments

@eygraber
Copy link

eygraber commented Jan 30, 2023

Considering the common confusion around Compose / Compose UI it might be helpful to add a small section to the README explaining the relationship between molecule and Compose UI:

  • You don't need to use Compose UI in order to use molecule
  • If your app is fully Compose UI you don't necessarily need to use molecule
    • If you don't need the output to be a StateFlow you don't need molecule and can call "presenter" functions (from Compose UI's composition) that return a State<T>
    • <Are there any pros to using molecule in this scenario?>
    • <Are there any cons to using molecule in this scenario?>
      • <The only one I can think of is increased complexity (however small) by introducing a new dependency, having an additional composition, etc...>
@ganfra
Copy link

ganfra commented Jan 31, 2023

To the question : Are there any cons to using molecule in this scenario?
I found using rememberSaveable wasn't working when the instance holding the moleculeScope is destroyed/recreated.
But maybe I did something wrong with my config.

@StylianosGakis
Copy link

Using molecule also gives you the power to scope that work to whatever class you're going to be holding it in. For example, as the PR here #274 shows, you can scope your molecule presenter to your AAC ViewModel, meaning that if the UI for whatever reason gets destroyed, like in a config change situation, your molecule presenter would persist for until the new UI comes on the screen after the config change.

So don't think it's as simple as, you're using compose UI -> No need for molecule.

@ganfra
Copy link

ganfra commented Aug 9, 2023

Using molecule also gives you the power to scope that work to whatever class you're going to be holding it in. For example, as the PR here #274 shows, you can scope your molecule presenter to your AAC ViewModel, meaning that if the UI for whatever reason gets destroyed, like in a config change situation, your molecule presenter would persist for until the new UI comes on the screen after the config change.

So don't think it's as simple as, you're using compose UI -> No need for molecule.

If you have a full compose UI app, most of the config changes are already handled at the Compose level, so you can avoid destroying the activity. Plus this is more the responsability of the data/domain layer to handle this properly instead of AAC ViewModel...

@StylianosGakis
Copy link

If you have a full compose UI app, most of the config changes are already handled

The key word here is "most", not all of them. So still relevant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants