MiddlewareScope
The scope that provides necessary operations for a middleware.
Functions
Properties
There is no equivalent to this in original Redux. It provides a current DispatchClosure. It remains immutable. However, elements inside might mutate depending on their implementation.
Extensions
Creates a dispatch function that consumes actions with given supertype T. Other actions are passed to the next middleware.
Returns CoroutineScope associated with a store.
This function only returns given dispatch. It has a few benefits over simple DispatchFunction lambda that are illustrated with this example:
Dispatches action and expects any middleware to launch a single foreground job logically associate with it. Coroutine is launched in a scope provided by DispatchCoroutineScope.
Dispatches action and expects any middleware to launch a single foreground job logically associate with it. This function suspends until foreground job is finished. When coroutine that calls this function is cancelled, foreground job is also cancelled.
Launches a foreground job using closure form this scope. By default, it's launched in a scope provided by DispatchCoroutineScope. This behaviour might be changed by dispatchJobIn or joinDispatchJob. Because this function uses local closure, calling it outside dispatch should not be done, because it might result in unexpected behaviour.
Runs given block as a coroutine in DispatchScope.coroutineScope. Effectively it ensures that any operation on a DispatchScope inside a block runs on proper thread.
Creates a dispatch function that executes a given block and passes every action to the next middleware.
Adds local changes to LocalClosureContainer with a given closure for a time of block execution.