Skip to content

Commit

Permalink
refactor mvi arch
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Dec 8, 2024
1 parent d3bf87e commit 94eee15
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package com.stslex.wizard.core.ui.mvi.handler

import com.stslex.wizard.core.ui.mvi.Store
import kotlinx.coroutines.flow.StateFlow

abstract class BaseHandler<in E : Handler.Event, S : Store.State, in A : Store.Action>(
private val store: Store<S, A, E>
) : Handler<E> {

val state: StateFlow<S>
get() = store.state

protected fun sendAction(action: A) {
store.sendAction(action)
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.stslex.wizard.core.ui.mvi.handler

import com.stslex.wizard.core.ui.mvi.Store
import com.stslex.wizard.core.ui.mvi.handler.Handler.Event

fun interface Handler<in E : Event> {

operator fun invoke(event: E)

interface Event : Store.Event
}

0 comments on commit 94eee15

Please sign in to comment.