{ class TakeSquare( val row: Int, val col: Int ) : Event() object Quit : Event() } private val events = PublishRelay.create<Event>() fun sendEvent(e: Event) = events.call(e)
{ class TakeSquare( val row: Int, val col: Int ) : Event() object Quit : Event() } private val events = PublishRelay.create<Event>() fun sendEvent(e: Event) = events.call(e)
{ abstract val turn: Turn data class Playing( override val turn: Turn ) : State() data class Completed( val ending: Ending, override val turn: Turn ) : State() } data class Turn( val players: Map<Symbol, String>, val playing: Symbol = X, val board: Board = EMPTY_BOARD )
{ abstract val turn: Turn data class Playing( override val turn: Turn ) : State() data class Completed( val ending: Ending, override val turn: Turn ) : State() }
{ abstract val turn: Turn data class Playing( override val turn: Turn ) : State() data class Completed( val ending: Ending, override val turn: Turn ) : State() } sealed class Ending { object Victor : Ending() object Draw : Ending() object Quitter : Ending() }
* @param eventHandler The object that accepts events for this screen. */ class Screen<D : Any, E : Any>( val data: D, val eventHandler: E ) typealias AnyScreen = Screen<*, *>
* @param eventHandler The object that accepts events for this screen. */ class Screen<D : Any, E : Any>( val data: D, val eventHandler: E ) typealias AnyScreen = Screen<*, *> /** * A [Workflow] that exposes its state as a stream * of [screen models][Screen]. */ typealias ScreenWorkflow<O> = Workflow<AnyScreen, O>
screen: T) -> View // Registers a factory block for the screen type `T`. public mutating func register<T: Screen>( screenType: T.Type, factory: @escaping (Observable<T>, ViewRegistry<View>) -> View // ... } The View Registry requires screens to be registered. 73