Skip to content

Commit

Permalink
Remove public subscribeTo function
Browse files Browse the repository at this point in the history
  • Loading branch information
alex2069 committed Mar 9, 2021
1 parent a40b389 commit 1408cec
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions rekotlin/src/main/kotlin/org/rekotlin/CompositeStore.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ private class CompositeStore<State>(

init {
stores.forEach { store ->
store.subscribeTo { _ ->
store.subscribeProjected { _ ->
val prevState = _state
val newState = compose(stores)
_state = newState
Expand Down Expand Up @@ -134,14 +134,10 @@ private class CompositeStore<State>(
}

private val Effect.isDispatching get() = effectDispatcher.isDispatching(this)
}

inline fun <State> Store<State>.subscribeTo(crossinline subscriber: (State) -> Unit) =
object : Subscriber<State> {
override fun newState(state: State) {
subscriber(state)
}
}.also { subscribe(it) }
private inline fun <State> Store<State>.subscribeProjected(crossinline subscriber: (State) -> Unit) =
subscribe(subscriber { subscriber(it) })
}

private class EffectDispatcher {
private val dispatching = mutableListOf<Effect>()
Expand Down

0 comments on commit 1408cec

Please sign in to comment.