StorePlugin

A unit that can extend the business logic of the Store. All stores are mostly based on plugins, and their behavior is entirely determined by them.

Plugins can influence subscription, stopping, and all other forms of store behavior. Access the store's context and other functions through the PipelineContext receiver. Plugins are typically made using StorePluginBuilder.

It is not recommended to implement this interface, instead, use one of the plugin builders

Properties

Link copied to clipboard
abstract val name: String?

The name of this plugin. The name can be used for logging purposes, but most importantly, to distinguish between different plugins. Name is optional, in which case the plugins will be compared by reference. If you attempt to StoreBuilder.install the same plugin, or different plugins with the same name, multiple times, an exception will be thrown. If you need to have the same plugin installed multiple times, consider giving plugins different names. Plugins that have no name can be installed multiple times, assuming they are different instances of a plugin. Consider the following examples:

Functions

Link copied to clipboard
abstract operator override fun equals(other: Any?): Boolean
Link copied to clipboard
abstract override fun hashCode(): Int
Link copied to clipboard
open operator override fun invoke(config: StoreConfiguration<S>): StorePlugin<S, I, A>

Create the StorePlugin using provided config

Link copied to clipboard
open suspend fun PipelineContext<S, I, A>.onAction(action: A): A?

A callback that is invoked each time an MVIAction has been sent. This is invoked after the action has been sent, but before the ActionConsumer handles it. This function will always be invoked, even after the action is later dropped because of ActionShareBehavior, and it will be invoked before the ActionReceiver.send returns, if it has been suspended.

Link copied to clipboard
open suspend fun PipelineContext<S, I, A>.onException(e: Exception): Exception?

A callback that is invoked when Store handles an exception. This is invoked before the exception is rethrown or otherwise processed. This is invoked asynchronously in a background job and after the job that has thrown was cancelled, meaning that some time may pass after the job is cancelled and the exception is handled. Handled exceptions do not result in Store.close.

Link copied to clipboard
open suspend fun PipelineContext<S, I, A>.onIntent(intent: I): I?

A callback which is invoked each time an MVIIntent is received and then begun to be processed. This callback is invoked after the intent is sent, sometimes after significant time if the store was stopped or even never if the store's buffer overflows or store is not ever used again.

Link copied to clipboard
open suspend fun PipelineContext<S, I, A>.onStart()

A callback that is invoked each time the Store.start is called.

Link copied to clipboard
open suspend fun PipelineContext<S, I, A>.onState(old: S, new: S): S?

A callback to be invoked each time StateReceiver.updateState or StateReceiver.withState is called. This callback is invoked before the state changes, and any plugin can veto (forbid) or modify the state change.

Link copied to clipboard
open fun onStop(e: Exception?)

Invoked when Store.close is invoked. This is called after the store is already closed, and you cannot influence the outcome. This is invoked for both exceptional stops and normal stops. Will not be invoked when an Error is thrown

Link copied to clipboard
open suspend fun PipelineContext<S, I, A>.onSubscribe(newSubscriberCount: Int)

A callback to be executed each time Store.subscribe is called.

Link copied to clipboard
open suspend fun PipelineContext<S, I, A>.onUnsubscribe(newSubscriberCount: Int)

A callback to be executed when the subscriber cancels its subscription job (unsubscribes).

Link copied to clipboard
abstract override fun toString(): String