Thread
#compose
    t

    Tim Malseed

    1 year ago
    I'm just getting started with compose.. I want to interop with Flow.. But this doesn't render a list:
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
    
        (view as ComposeView).setContent {
            view.setContent {
                MaterialTheme {
                    GenreList(genreRepository.getGenres(GenreQuery.All()))
                }
            }
        }
    }
    
    
    @Composable
    fun GenreList(genres: Flow<List<Genre>>) {
        val genreState = genres.collectAsState(initial = emptyList())
        LazyColumnFor(
            items = genreState.value,
            itemContent = { genre ->
                Text(text = genre.name)
            }
        )
    }
    If I pass in a (populated)
    List<Genre>
    instead of a
    Flow<List<Genre>>
    , things work OK
    Nevermind, I'm just dumb.
    (view as ComposeView).setContent {
                view.setContent {