copper-leaf / ballast

Opinionated Application State Management framework for Kotlin Multiplatform
https://copper-leaf.github.io/ballast/
BSD 3-Clause "New" or "Revised" License
144 stars 11 forks source link

awaitViewModelStart not awaiting #46

Closed asapha closed 1 year ago

asapha commented 1 year ago

Unless I'm missing something, the current implementation of awaitViewModelStart doesn't do anything, as take isn't a terminal operator.

/**
 * Suspend until the ViewModel has started
 */
public suspend inline fun <Inputs : Any, Events : Any, State : Any> Flow<BallastNotification<Inputs, Events, State>>.awaitViewModelStart() {
    filter {
        it is BallastNotification.ViewModelStatusChanged<Inputs, Events, State> && it.status == Status.Running
    }.take(1)
}
cjbrooks12 commented 1 year ago

Oh dang, you're right, nice catch. Looks like I accidentally switched it from first() to take(1) with the 3.0.0 release. I'll get a fix released shortly

cjbrooks12 commented 1 year ago

This should be fixed now in v3.0.2