https://kotlinlang.org logo
#android
Title
# android
p

pers

02/29/2024, 4:57 PM
I am writing new analytics new model, what you think 🤔 , I can see it complex enough
Copy code
sealed class Event : UiEvent(), EventTracked {
    data class Initial(override val analyticsEvent: AnalyticsEvent = SimpleEvent("")) : Event()
    data class BookNowClicked(override val analyticsEvent: AnalyticsEvent = BookingEvent("BookingEvent")) : Event()
    data class SelectedGuestCountChanged(val guestCount: Int, override val analyticsEvent: AnalyticsEvent = SimpleEvent("")) : Event()
}
Copy code
viewModelScope.launch {
    events.onEach {
        if (it is EventTracked)
            analyticsEvents.emit(it.analyticsEvent)
    }.collect {
        handleEvent(it)
    }
}
Copy code
private fun collectAnalyticsEvents() {
    viewModelScope.launch {
        analyticsEvents
            .collect {
                analyticsTrackerPort.trackEvent(it)
            }
    }
}