PresentationAction

A wrapper type for actions that can be presented.

PresentationReducer.swift:260
enum PresentationAction<Action>

Use this wrapper type for modeling a feature’s domain that needs to present a child feature using Reducer/ifLet(_:action:destination:fileID:filePath:line:column:)-4ub6q.

For example, if you have a ChildFeature reducer that encapsulates the logic and behavior for a feature, then any feature that wants to present that feature will hold onto ChildFeature.Action like so:

@Reducer
struct ParentFeature {
  // ...
  enum Action {
    case child(PresentationAction<ChildFeature.Action>)
     // ...
  }
  // ...
}

The PresentationAction enum has two cases that represent the two fundamental operations you can do when presenting a child feature: presented(_:) represents an action happening inside the child feature, and dismiss represents dismissing the child feature by nil-ing its state.

See the dedicated article on Navigation for more information on the library’s navigation tools, and in particular see Tree-based navigation for information on modeling navigation using optionals and enums.