birdsofparadise
12/24/2020, 6:43 PMeventually
Compose will replace Fragments? Looking at the Compose navigation feature it leads me to believe that.rsktash
12/24/2020, 7:45 PMbirdsofparadise
12/24/2020, 8:05 PMAdam Powell
12/24/2020, 8:16 PMbirdsofparadise
12/24/2020, 8:17 PMAdam Powell
12/24/2020, 8:21 PMbirdsofparadise
12/24/2020, 8:22 PMbirdsofparadise
12/24/2020, 8:23 PMAdam Powell
12/25/2020, 12:52 AMKshitij Patil
12/25/2020, 1:14 AMImmutable
state objects to Composables. This way, you can preview your Screen at different states, test it independently and if suitable, reuse the Screen Composable in multiple Fragments. Passing viewmodel directly to the Composables seems too tight coupling to me as you might end up writing some of the UI logic in ViewModels.
I was also in the similar impression initially but doing it this way seems like getting best of both the worlds as of now.birdsofparadise
12/25/2020, 1:18 AMKshitij Patil
12/25/2020, 6:13 AMMutableState
variables inside a ViewModel to hold some UI state which I feel is a bad idea as you won't be able to use same ViewModel with lagacy xml layouts.
And Compose plays excellent with sealed classes so if you're using it right, you'll never write UI logic outside a Composable. It's really a great privilege to be able to use control structures like if
else
, kotlin's let
run
with
etc. to conditionally show or hide Composables. No more need write binding adapters and stuff, in Compose, you can write plain Kotlin and it'll just work.
You can fire a coroutine right from a Composable, I mean the list just continues.