Builder

interface Builder<M, E, F> : MobiusLoop.Factory<M, E, F>

Defines a fluent API for configuring a MobiusLoop. Implementations must be immutable, making them safe to share between threads.

Parameters

M

the model type

E

the event type

F

the effect type

Functions

Link copied to clipboard
abstract fun effectRunner(effectRunner: Producer<WorkRunner>): MobiusLoop.Builder<M, E, F>
Link copied to clipboard
abstract fun eventRunner(eventRunner: Producer<WorkRunner>): MobiusLoop.Builder<M, E, F>
Link copied to clipboard
abstract fun eventSource(eventSource: Connectable<M, E>): MobiusLoop.Builder<M, E, F>

Returns a new Builder with the supplied Connectable, and the same values as the current one for the other fields. NOTE: Invoking this method will replace the current event source with the supplied one. If a loop has a Connectable as its event source, it will connect to it and will invoke the Connection accept method every time the model changes. This allows us to conditionally subscribe to different sources based on the current state. If you provide a regular EventSource, it will be wrapped in a Connectable and that implementation will subscribe to that event source only once when the loop is initialized.

abstract fun eventSource(eventSource: EventSource<E>): MobiusLoop.Builder<M, E, F>
Link copied to clipboard
abstract fun eventSources(vararg eventSources: EventSource<E>): MobiusLoop.Builder<M, E, F>
Link copied to clipboard
abstract fun init(init: Init<M, F>): MobiusLoop.Builder<M, E, F>
Link copied to clipboard
abstract fun logger(logger: MobiusLoop.Logger<M, E, F>): MobiusLoop.Builder<M, E, F>
Link copied to clipboard
abstract fun startFrom(startModel: M): MobiusLoop<M, E, F>

Start a MobiusLoop using this factory.

abstract fun startFrom(startModel: M, startEffects: Set<F>): MobiusLoop<M, E, F>

Start a {@link MobiusLoop} using this factory.