DecoratorBuilder

This is a builder object for PluginDecorator. It wraps another StorePlugin and implements the StorePlugin interface.

Decorators can wrap an individual plugin (using PluginDecorator.decorates), in which case they are pretty much normal decorators and you can access the underlying plugin using the parameter of a method.

However, if a decorator is installed over the entire store (in the StoreBuilder), it will wrap ALL of the store's plugins, expressed as a single compositePlugin.

Decorators are very similar to plugins, but they differ in these ways:

  • Decorators are installed after all of the plugins in a store. It means, that if you install a decorator to the StoreBuilder, it will wrap all plugins of a store.

  • Decorators are installed in the order they are declared. If a decorator is installed after another, it will wrap all previous decorators with itself, which in turn wrap all plugins.

  • Decorators can be used to manipulate the plugin chain in more ways than plugins. For example, unlike plugins, if you do not invoke the appropriate method of the child plugin manually, it will skip the entire chain.

  • Values you return from decorator methods are not the "next" values like with plugins, but should be treated as the final values, i.e, if you return a state, it will be the state that the store will have, unless this decorator is decorated by another one

Warning:

Decorators are experimental and currently are waiting for context parameter support to enable the correct DSL. The current DSL is temporary, and as such, there WILL be at least one breaking change before these go stable, it may even be a behavioral one. If you use these, monitor the release notes for changes in the API and, if possible, stick to built-in decorators.**

Builder methods will throw IllegalArgumentException if they are assigned multiple times. Each plugin can only have one block per each type of StorePlugin callback.

Properties

Link copied to clipboard
var name: String?

The name of the decorator. Must be unique if defined. The same rules apply as for the StorePlugin.name property

Functions

Link copied to clipboard
fun onAction(block: DecorateValue<S, I, A, A>)

Wraps the StorePlugin.onAction method of the child plugin passed in the block parameter.

Link copied to clipboard

Wraps the StorePlugin.onException method of the child plugin passed in the block parameter.

Link copied to clipboard
fun onIntent(block: DecorateValue<S, I, A, I>)

Wraps the StorePlugin.onIntent method of the child plugin passed in the block parameter.

Link copied to clipboard
fun onStart(block: Decorate<S, I, A>)

Wraps the StorePlugin.onStart method of the child plugin passed in the block parameter.

Link copied to clipboard
fun onState(block: DecorateState<S, I, A>)

Wraps the StorePlugin.onState method of the child plugin passed in the block parameter.

Link copied to clipboard

Wraps the StorePlugin.onStop method of the child plugin passed in the block parameter.

Link copied to clipboard
fun onSubscribe(block: DecorateArg<S, I, A, Int>)

Wraps the StorePlugin.onSubscribe method of the child plugin passed in the block parameter.

Link copied to clipboard

Wraps the StorePlugin.onUndeliveredAction method of the child plugin passed in the block parameter.

Link copied to clipboard

Wraps the StorePlugin.onUndeliveredIntent method of the child plugin passed in the block parameter.

Link copied to clipboard
fun onUnsubscribe(block: DecorateArg<S, I, A, Int>)

Wraps the StorePlugin.onUnsubscribe method of the child plugin passed in the block parameter.