Type Aliases
The following type aliases are available globally.
-
Typealias for the function that is invoked to continue with the interceptors chains.
Declaration
Swift
public typealias StoreInterceptorNext = (Dispatchable) throws -> Void -
An interceptor is like a catch-all system that can be used to implement functionalities such as logging, or to dynamically change the behaviour of the store. An interceptor is invoked every time something has been dispatched and it is about to be handled.
Initialization
When the store is initialised, the first closure is invoked and the interceptor receives the context passed to the side effects. The interceptor can later use this context to retrieve the state or to dispatch new items.
This step is performed once in the store lifetime.
Receiving Next
When the dispatchable is about to be handled, the store invokes the second function and passes
nextto the interceptor.Nextis a generic way to pass the next step of the interceptors chaining.The interceptor should save this value and use it in the next step.
This step is performed multiple times in the store lifetime, once for each dispatchable item handled by the store.
Receiving the dispatchable
Before handling the dispatchable (e.g., update the state in case of a
StateUpdater). The last closure is invoked.Here the interceptor can do anything it needs to in order to implement the desired behaviour. Eventually, though, it should either invoke
nextpassing the dispatchable (that is, the chain continues) or throw an error, which will reject the related promise and will make so that the operation related to the dispatchable is not performed.The
nextmethod can be also invoked with a different dispatchable with respect to the received one.This step is performed multiple times in the store lifetime, once for each dispatchable item handled by the store.
Declaration
Swift
public typealias StoreInterceptor = (_ sideEffectContext: AnySideEffectContext) -> (_ next: @escaping StoreInterceptorNext) -> (_ dispatchable: Dispatchable) throws -> Void -
Typealias for the function that is invoked when the state changes.
Declaration
Parameters
oldStatethe state before the update
newStatethe state after the update
-
Typealias for the function that is invoked when the state changes.
Declaration
Swift
public typealias StoreListener<S> = (_ oldState: S, _ newState: S) -> Void where S : StateParameters
oldStatethe state before the update
newStatethe state after the update
-
Typealias for the
Storelistener unsubscribe closureDeclaration
Swift
public typealias StoreUnsubscribe = () -> Void -
Typealias for the
Store.anyDispatchfunction with the ability of managing the output with a promiseDeclaration
Swift
public typealias AnyDispatch = (Dispatchable) -> Promise<Any>
View on GitHub
Type Aliases Reference