https://kotlinlang.org logo
t

Tristan

02/03/2020, 12:44 AM
Is there an example of how to use
model
along side
ambient
? If any of you is coming from Angular and could make a little comparaison for understanding, that would be great 😮 I would do something
Copy code
class UserService {
    // ...
    privatte val event = ConflatedBroadcastChannel<User>()
    val user = event.asFlow()

    fun login(val args: Any) {
        // ...
        event.offer(User())
    }
}

@Composable
fun UserCard() {
    var userService by inject<UserService>()

    userService.user.onEach {
        Text(it.name)
    }.launchIn(ComponentContext)
}
Of course, I am sure there is better, and I know coroutines are not properly supported yet 😄 Please, guide me