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 orSignalProducer
from ReactiveCocoa.Declaration
Swift
func call() -> ResponseType
-
The return type from the
call
method.Note
This is inferred from thecall
method implementation.Declaration
Swift
typealias ResponseType