StoreBuilder

A builder DSL for creating a Store. Cannot be instantiated outside of store functions. After building, the StoreConfiguration is created and used in the Store.

Parameters

initial

initial state the store will have.

Properties

Link copied to clipboard
val initial: S

Functions

Link copied to clipboard
inline fun <T, S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.asyncCache(context: CoroutineContext = EmptyCoroutineContext, start: CoroutineStart = CoroutineStart.UNDISPATCHED, crossinline init: suspend PipelineContext<S, I, A>.() -> T): CachedValue<Deferred<T>, S, I, A>

Install a new cachePlugin that will run the init in an asynchronous way and return a Deferred that can be used to await the value.

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.asyncInit(context: CoroutineContext = EmptyCoroutineContext, crossinline block: suspend PipelineContext<S, I, A>.() -> Unit)

initPlugin overload that launches a new coroutine instead of preventing store startup sequence.

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.awaitSubscribers(manager: SubscriberManager = SubscriberManager(), minSubs: Int = 1, suspendStore: Boolean = true, timeout: Duration = Duration.INFINITE, name: String = SubscriberManager.Name): SubscriberManager

Installs a new awaitSubscribersPlugin

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.batchIntents(mode: BatchingMode, name: String? = "BatchIntentsDecorator"): BatchQueue<I>

Installs a new batchIntentsDecorator for all plugins of this store.

Link copied to clipboard
fun <T, S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.cache(name: String? = null, init: suspend PipelineContext<S, I, A>.() -> T): CachedValue<T, S, I, A>

Creates and installs a new CachedValue, returning a delegate that can be used to get access to the property that was cached. Please consult the documentation of the parent class to understand how to use this plugin.

Link copied to clipboard
inline fun configure(block: StoreConfigurationBuilder.() -> Unit)

Adjust the current StoreConfiguration of this Store.

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.conflateActions(name: String? = "ConflateActions", crossinline compare: (it: A, other: A) -> Boolean = MVIAction::equals)

Installs a new conflateActionsDecorator for all actions in this store.

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.conflateIntents(name: String? = "ConflateIntents", crossinline compare: (it: I, other: I) -> Boolean = MVIIntent::equals)

Returns a new conflateIntentsDecorator for all intents in this store.

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.consumeIntents(name: String = ConsumeIntentsPluginName)

Create and install a plugin that consumes intents and does nothing with them.

Link copied to clipboard
infix inline fun decorate(block: DecoratorBuilder<S, I, A>.() -> Unit)

Create and install a new PluginDecorator that will decorate all plugins of this store and all decorators installed before this one!

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.deinit(crossinline block: ShutdownContext<S, I, A>.(e: Exception?) -> Unit)

Install a new deinitPlugin.

Link copied to clipboard

Installs a new disallowRestartPlugin. Please consult the docs of the parent function to learn more. This plugin can only be installed only once.

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.enableLogging(tag: String? = null, level: StoreLogLevel? = null, name: String? = null, logger: StoreLogger? = null)

Install a new loggingPlugin.

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.init(block: suspend PipelineContext<S, I, A>.() -> Unit)

Installs a plugin that invokes block when pro.respawn.flowmvi.api.Store.start is called.

Link copied to clipboard

Alias for install

@JvmName(name = "decorate")
fun PluginDecorator<S, I, A>.install()

Install this decorator. Decorator will be installed after all plugins and decorators installed before, and it will wrap all of them, expressed as a single compositePlugin.

infix inline fun install(crossinline block: LazyPluginBuilder<S, I, A>.() -> Unit)

Create and install a new StorePlugin. Please see documentation for the other overload for more details.

infix fun install(plugins: Iterable<LazyPlugin<S, I, A>>)
fun install(plugin: LazyPlugin<S, I, A>, vararg other: LazyPlugin<S, I, A>)

Install StorePlugins. See the other overload to build the plugin on the fly. This installs prebuilt plugins.

@JvmName(name = "decorate")
infix fun install(decorators: Iterable<PluginDecorator<S, I, A>>)

Install the decorators. Decorators will be installed after all plugins in the order they are in the list, and they will wrap all of the plugins of this store, expressed as a single compositePlugin.

@JvmName(name = "decorate")
fun install(decorator: PluginDecorator<S, I, A>, vararg other: PluginDecorator<S, I, A>)

Install these decorators. Decorators will be installed after all plugins in the order they are declared. and they will wrap all of the plugins of this store, expressed as a single compositePlugin.

Link copied to clipboard
fun <K : Any, A : MVIAction, I : MVIIntent, S : MVIState> StoreBuilder<S, I, A>.manageJobs(jobs: JobManager<K> = JobManager(), name: String = JobManager.Name): JobManager<K>

Create and install a new plugin that uses JobManager to manage running jobs. The plugin will cancel all running jobs if the store is closed.

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.recover(name: String? = null, recover: Recover<S, I, A>)

Create and install a recoverPlugin.

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.reduce(consume: Boolean = true, name: String = ReducePluginName, crossinline reduce: Reduce<S, I, A>)

Create and install a reducePlugin.

Link copied to clipboard
fun <S : MVIState, A : MVIAction> StoreBuilder<S, LambdaIntent<S, A>, A>.reduceLambdas(name: String = ReducePluginName, consume: Boolean = true)

Install a new pro.respawn.flowmvi.plugins.reducePlugin that is tailored for LambdaIntents.

Link copied to clipboard
Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.retryActions(strategy: RetryStrategy = RetryStrategy.Default, name: String? = null, crossinline selector: (action: A, e: Exception) -> Boolean = { _, _ -> true })

Install a retryActionsDecorator over this Store.

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.retryIntents(strategy: RetryStrategy = RetryStrategy.Default, name: String? = null, crossinline selector: (intent: I, e: Exception) -> Boolean = { _, _ -> true })

Install a retryIntentsDecorator over this Store.

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.timeoutIntents(timeout: Duration, name: String? = "IntentTimeout", crossinline onTimeout: suspend PipelineContext<S, I, A>.(I) -> I? = { throw StoreTimeoutException(timeout) })

Installs a new intentTimeoutDecorator for all intents in this store.

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.timeTravel(historySize: Int = TimeTravel.DefaultHistorySize, name: String = TimeTravel.Name): TimeTravel<S, I, A>

Create a new TimeTravel and installs it. Keep a reference to the returning value to use its properties.

fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.timeTravel(timeTravel: TimeTravel<S, I, A>, name: String = TimeTravel.Name)

Create a new TimeTravel and installs it. Keep a reference to the object to use its properties.

Link copied to clipboard
fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.undoRedo(maxQueueSize: Int, name: String? = null, resetOnException: Boolean = true): UndoRedo

Creates, installs and returns a new UndoRedo instance

Link copied to clipboard
inline fun <S : MVIState, I : MVIIntent, A : MVIAction> StoreBuilder<S, I, A>.whileSubscribed(name: String? = null, minSubscriptions: Int = 1, crossinline block: suspend PipelineContext<S, I, A>.() -> Unit)

Create and install a new whileSubscribed plugin. See the parent's function docs for more info.