All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.com.copperleaf.ballast.undo.state.StateBasedUndoControllerEventHandler.kt Maven / Gradle / Ivy

There is a newer version: 4.2.1
Show newest version
package com.copperleaf.ballast.undo.state

import com.copperleaf.ballast.EventHandler
import com.copperleaf.ballast.EventHandlerScope
import com.copperleaf.ballast.undo.UndoScope

internal class StateBasedUndoControllerEventHandler(
    private val undoScope: UndoScope
) : EventHandler<
        StateBasedUndoControllerContract.Inputs,
        StateBasedUndoControllerContract.Events,
        StateBasedUndoControllerContract.State> {
    override suspend fun EventHandlerScope<
            StateBasedUndoControllerContract.Inputs,
            StateBasedUndoControllerContract.Events,
            StateBasedUndoControllerContract.State>.handleEvent(
        event: StateBasedUndoControllerContract.Events,
    ) = when (event) {
        is StateBasedUndoControllerContract.Events.RestoreState -> {
            undoScope.restoreState(event.stateToRestore)
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy