Action

@available(*, deprecated, message: "Use AnyStateUpdater instead")
public protocol Action : Dispatchable

An action represents an event that leads to a change in the state of the application. It can be triggered from a user action, from a system event or any event in general.

  • Creates the new state starting from the current state and the action. It is important to note that updateState(currentState:action:) should be a pure function, that is a function that given the same input always returns the same output and it also doesn’t have any side effect. This is really important because it is an assumption that Katana (and related tools) makes in order to implement some functionalities (e.g., not implemented yet, but possible in the future: time travel)

    Declaration

    Swift

    func updatedState(currentState: State) -> State

    Parameters

    state

    the current state

    action

    the action that has been dispatched

    Return Value

    the new state