Skip to content

Commit

Permalink
fun test function handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
stslex committed Dec 9, 2024
1 parent 952190f commit 9c52b56
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
package com.stslex.wizard.feature.profile.mvi

import com.stslex.wizard.core.ui.mvi.v2.Handler
import com.stslex.wizard.core.ui.mvi.v2.HandlerStore
import com.stslex.wizard.core.ui.mvi.v2.handler
import com.stslex.wizard.feature.profile.ui.store.ProfileStore.Action
import com.stslex.wizard.feature.profile.ui.store.ProfileStore.Action.Click
import com.stslex.wizard.feature.profile.ui.store.ProfileStore.Event
import com.stslex.wizard.feature.profile.ui.store.ProfileStore.State

class ClickersHandler : Handler<State, Click, Event, Action>(Click::class) {

override fun HandlerStore<State, Action, Event>.invoke(action: Click) {
when (action) {
Click.BackButtonClick -> sendAction(Action.Navigation.Back)
Click.FavouriteClick -> sendAction(Action.Navigation.Favourite(state.value.uuid))
Click.FollowersClick -> sendAction(Action.Navigation.Followers(state.value.uuid))
Click.FollowingClick -> sendAction(Action.Navigation.Following(state.value.uuid))
Click.SettingsClick -> sendAction(Action.Navigation.Settings)
}
fun clickersHandler(): Handler<State, Click, Event, Action> = handler { action ->
when (action) {
Click.BackButtonClick -> sendAction(Action.Navigation.Back)
Click.FavouriteClick -> sendAction(Action.Navigation.Favourite(state.value.uuid))
Click.FollowersClick -> sendAction(Action.Navigation.Followers(state.value.uuid))
Click.FollowingClick -> sendAction(Action.Navigation.Following(state.value.uuid))
Click.SettingsClick -> sendAction(Action.Navigation.Settings)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import com.stslex.wizard.core.database.store.UserStore
import com.stslex.wizard.core.navigation.navigator.Navigator
import com.stslex.wizard.core.ui.mvi.v2.BaseStore
import com.stslex.wizard.feature.profile.domain.interactor.ProfileInteractor
import com.stslex.wizard.feature.profile.mvi.ClickersHandler
import com.stslex.wizard.feature.profile.mvi.InitStorageHandler
import com.stslex.wizard.feature.profile.mvi.LogoutHandler
import com.stslex.wizard.feature.profile.mvi.NavigationHandler
import com.stslex.wizard.feature.profile.mvi.RepeatLastActionHandler
import com.stslex.wizard.feature.profile.mvi.clickersHandler
import com.stslex.wizard.feature.profile.ui.store.ProfileStore.Action
import com.stslex.wizard.feature.profile.ui.store.ProfileStore.Event
import com.stslex.wizard.feature.profile.ui.store.ProfileStore.State
Expand All @@ -23,7 +23,8 @@ class ProfileStoreImpl(
InitStorageHandler(interactor, userStore),
LogoutHandler(interactor),
RepeatLastActionHandler(),
ClickersHandler(),
clickersHandler(),
NavigationHandler(navigator)
)
)

0 comments on commit 9c52b56

Please sign in to comment.