core/client/src/jsMain/kotlin/dev/inmo/postssystem/client/fsm/ui/JSView.kt

19 lines
684 B
Kotlin
Raw Normal View History

2021-11-24 07:52:27 +00:00
package dev.inmo.postssystem.client.fsm.ui
import dev.inmo.postssystem.client.ui.fsm.UIFSMHandler
import dev.inmo.postssystem.client.ui.fsm.UIFSMState
import dev.inmo.micro_utils.fsm.common.StatesMachine
2022-01-22 16:59:41 +00:00
import kotlinx.browser.document
2021-11-24 07:52:27 +00:00
import org.w3c.dom.HTMLElement
abstract class JSView<T : UIFSMState> : UIFSMHandler<T> {
open suspend fun StatesMachine<in UIFSMState>.safeHandleState(
htmlElement: HTMLElement,
state: T
): UIFSMState? = null
override suspend fun StatesMachine<in UIFSMState>.safeHandleState(state: T): UIFSMState? {
2022-01-22 16:59:41 +00:00
return safeHandleState(document.getElementById(state.context) as? HTMLElement ?: return null, state)
2021-11-24 07:52:27 +00:00
}
}