AnyStore

public protocol AnyStore : AnyObject

Type Erasure for Store

  • Type Erasure for the Store state

    Declaration

    Swift

    var anyState: State { get }
  • Dispatches a generic Dispatchable item. This is useful for customizing Katana’s dispatchable, for example in other libraries.

    Declaration

    Swift

    @discardableResult
    func anyDispatch(_ dispatchable: Dispatchable) -> Promise<Any>

    Parameters

    dispatchable

    the item to dispatch

    Return Value

    a promise that is resolved when the dispatchable is handled by the store, resolving to a value associated with the dispatchable

  • Dispatches an AnyStateUpdater item

    Declaration

    Swift

    @discardableResult
    func dispatch<T>(_ dispatchable: T) -> Promise<Void> where T : AnyStateUpdater

    Parameters

    dispatchable

    the State Updater to dispatch

    Return Value

    a promise that is resolved when the dispatchable is handled by the store

  • Dispatches an AnySideEffect item

    Declaration

    Swift

    @discardableResult
    func dispatch<T>(_ dispatchable: T) -> Promise<Void> where T : AnySideEffect

    Parameters

    dispatchable

    the State Updater to dispatch

    Return Value

    a promise that is resolved when the dispatchable is handled by the store

  • Dispatches a ReturningSideEffect item

    Declaration

    Swift

    @discardableResult
    func dispatch<T>(_ dispatchable: T) -> Promise<T.ReturnValue> where T : ReturningSideEffect

    Parameters

    dispatchable

    the Returning Side Effect to dispatch

    Return Value

    a promise parameterized to the side effect’s return value, that is resolved when the dispatchable is handled by the store

  • Adds a listener to the store. A listener is basically a closure that is invoked every time the Store’s state changes

    Declaration

    Swift

    func addAnyListener(_ listener: @escaping AnyStoreListener) -> StoreUnsubscribe

    Parameters

    listener

    the listener closure

    Return Value

    a closure that can be used to remove the listener