Typealiases

The following typealiases are available globally.

  • An ActionCreator is a function that, based on the received state argument, might or might not create an action.

    Example:

    func deleteNote(noteID: Int) -> ActionCreator {
     return { state, store in
        // only delete note if editing is enabled
        if (state.editingEnabled == true) {
            return NoteDataAction.DeleteNote(noteID)
        } else {
            return nil
        }
     }
    }
    

    Declaration

    Swift

    public typealias ActionCreator = (state: StateType, store: Store) -> Action?
  • An optional callback that can be passed to the dispatch method. This callback will be called when the dispatched action triggers a new state calculation. This is useful when you need to wait on a state change, triggered by an action (e.g. wait on a successful login). However, you should try to use this callback very seldom as it deviates slighlty from the unidirectional data flow principal.

    Declaration

    Swift

    public typealias DispatchCallback = (StateType) -> Void
  • AsyncActionCreators allow the developer to wait for the completion of an async action.

    Declaration

    Swift

    public typealias AsyncActionCreator = (state: StateType, store: Store,