DynamicActionType

public protocol DynamicActionType

This protocol is used when you want to do some async behavior that updates the store. It is very minimal in that it’s not allowed to modify the store directly. The async behavior is done within the call method and to make changes it should dispatch a synchronous action.

Sample Action:

struct FetchUsers: DynamicActionType {
    func call() {
        someApi.fetchUsers { users in
            store.dispatch(SetUsersAction(users: users))
        }
    }
}

store.dispatch(UpdateIdAction(id: 1))
  • This method is where you perform some async behavior that when completed, should dispatch a synchronous action on the store.

    You can optionally return an object that wraps async behavior. This might be a Promise from PromiseKit or SignalProducer from ReactiveCocoa.

    Declaration

    Swift

    func call() -> ResponseType
  • The return type from the call method.

    Note

    This is inferred from the call method implementation.

    Declaration

    Swift

    typealias ResponseType