Classes

The following classes are available globally.

  • This object represents a single action in an ActionPerformableCollection object. The actual work done is handled by an Interactor; this object calls asyncRequestForAction(destination:actionType:content:resultTransformer:) on its assistant, and upon completion adds its result to a results array it passes along to this step’s output conduit. If there is no conduit attached, it will assume the sequence is completed and return all results. If the action’s task is cancelled an cancelled(partialResults:) error will be returned; if the interactor returns a failure an ActionError/failed(partialResults:) error will be returned, both with the accumulated results that completed previously in the sequence.

    Note

    Generally you should not create this object directly. Instead, ActionConfiguration objects should be used to represent sequence steps in conjunction with an ActionSequenceConfiguration object.

    See more

    Declaration

    Swift

    @MainActor
    public final class Action<InteractorType, ContentType> : ActionPerformable where InteractorType : InteractorTypeable, ContentType : ContentTypeable
  • An ActionPerformable conforming type which selects and runs one of several actions based on provided conditions, evaluated against the current content and previous results in a sequence and runs the first path whose conditions return true. Branches are mainly only used as a step in an ActionSequence.

    ActionBranch evaluates its BranchConditionable conditions in declaration order and runs the first path whose condition (or conditions, if a group condition like AllSatisfyCondition or AnySatisfyCondition is used) returns true. If no condition matches and there’s no fallback action, the branch fails with cancelled(partialResults:). To guarantee a fallback path, you can add on an .otherwise path at the end of the branch chain. After the selected path action completes, ActionBranch applies the path’s optional transformer to the result and forwards the content through its own output conduit to the next sequence step, recording one ActionResult with origin branch.

    In the example below, if there are images passed-in from the previous step, it will process the images with a filter. If instead the content is text, it will render the text into an image. If neither was provided, it will choose the fallback action. This branch object could then be used as a sequence step or in a group of actions.

    let branch = ActionBranchConfiguration<AppInteractorType, AppContentType>()
        .branch(when: HasImagesCondition(), action: processImageStep)
        .branch(when: HasTextCondition(),   action: renderTextStep)
        .otherwise(fallbackAction)
    

    Note

    Do not instantiate this type directly. Use ActionBranchConfiguration to define and build a branch step.

    See more

    Declaration

    Swift

    @MainActor
    public final class ActionBranch<ContentType> : ActionPerformable where ContentType : ContentTypeable
  • A group of actions which run concurrently, merging their results into one content value.

    The child requests all run concurrently and receive the same input content. When they complete, a ActionResultsMerging object merges their results into a single content value. The group passes this content value and all of the group’s child results via a single ActionResult, and passes the merged value on through its output conduit.

    Child failure behavior

    Each child’s shouldEndParentTaskOnFailure flag controls what happens when that child fails:

    • true: The group immediately calls cancelAll() on its remaining siblings, builds a group-level ActionResult containing all results collected up to that point plus the failing child’s failure result, and returns cancelled(partialResults:). Siblings that had not yet completed are cancelled.

    • false: The group records the failure and lets all remaining siblings run to completion. Once every child has finished, the group builds a single group-level ActionResult whose origin property includes child results for every task’s success or failure in declaration order, then returns cancelled(partialResults:). The merger is not called because not all children succeeded.

    In both cases the caller receives one group ActionResult with a group(results:) origin. Use failedActions() on the partial results to inspect which children failed.

    Note

    You should not instantiate an ActionGroup directly. Instead you should create an ActionGroupConfiguration object to define it, and used in conjunction with performActions(configuration:content:).

    Usage

    Build a group by composing child ActionConfiguration objects inside an ActionGroupConfiguration. You can either assign this configuration to interactorsData and run it via its associated event type, or you can build these configurations within a state model and call performActions(configuration:content:) on its Destination.

    // Each child configuration represents one parallel Interactor request.
    let retrievalChildren: [any ActionConfiguring<InteractorType, ContentType>] = [
        ActionConfiguration<InteractorType, ContentType, MyInteractor>(
            interactorType: .myType,
            action: .retrieveFile,
            assistant: .basicAsync,
            identifier: ActionIdentifier.retrieve),
        ActionConfiguration<InteractorType, ContentType, MyInteractor>(
            interactorType: .myType,
            action: .retrieveFile,
            assistant: .basicAsync,
            identifier: ActionIdentifier.retrieve)
    ]
    
    // The merger combines each child's result into a single ContentType value.
    let retrievals = ActionGroupConfiguration<InteractorType, ContentType>(
        actions: retrievalChildren,
        merger: FileMerger(),
        identifier: ActionIdentifier.retrievalGroup)
    
    let result = await destination.performActions(configuration: retrievals, content: nil)
    
    if case .success(let outputs) = result,
       let groupResult = outputs.last(identifier: ActionIdentifier.retrievalGroup) {
        // groupResult.content holds the merged value from all parallel children.
    }
    
    See more

    Declaration

    Swift

    @MainActor
    public final class ActionGroup<ContentType> : ActionPerformableCollection where ContentType : ContentTypeable
  • This object controls a sequence of actions that are run in serial order, passing output from one sequence step to the next.

    ActionSequence manages a chain of ActionPerformable steps connected by output conduits. Each step receives the content produced by the previous step via its output conduit. The sequence is run starting from the first action, which signals each action to run successively in order. A sequence step can also be an ActionGroup, which runs a collection of actions in parallel.

    Note

    Generally you should not instantiate an ActionSequence directly. Instead you should use an ActionSequenceConfiguration object to build it. You can either assign this configuration to DestinationProviding/interactorsData and run it via its associated event type, or you can build these configurations within a state model and call Destinationable/performActions(configuration:content:)-c2a7 on its Destination.

    Usage

    Build a sequence by composing ActionConfiguration steps inside an ActionSequenceConfiguration using the .step(_:inputTransformer:) builder API. Each call to .step(_:) automatically links the previous step’s output to the new step; the optional inputTransformer converts that output before the new step receives it.

    // Step 1: retrieve data from an interactor.
    let retrievalStep = ActionConfiguration<InteractorType, ContentType, FetchInteractor>(
        interactorType: .api,
        action: .retrieve,
        assistant: .basicAsync,
        identifier: ActionIdentifier.retrieve)
    
    // Step 2: process the retrieved data.
    let processStep = ActionConfiguration<InteractorType, ContentType, ProcessInteractor>(
        interactorType: .process,
        action: .transform,
        assistant: .basicAsync,
        identifier: ActionIdentifier.process)
    
    // Link the steps: retrievalStep's output is transformed and passed into processStep.
    let filesSequence = ActionSequenceConfiguration<InteractorType, ContentType>(identifier: ActionIdentifier.fileSequence)
        .step(retrievalStep)
        .step(processStep, inputTransformer: FileTransformer())
    
    // Run the actions and inspect the accumulated results.
    let result = await destination.performActions(configuration: filesSequence, content: nil)
    
    if case .success(let outputs) = result,
       let processResult = outputs.last(identifier: ActionIdentifier.fileSequence),
       case .savedFiles(let urls) = processResult.content {
        // processResult.content holds the final transformed value.
    }
    
    See more

    Declaration

    Swift

    @MainActor
    public final class ActionSequence<ContentType> : ActionPerformableCollection where ContentType : ContentTypeable
  • A container class for Destination presentation configuration models, which are used by a Destination to present new Destinations.

    See more

    Declaration

    Swift

    public final class AppDestinationConfigurations<EventType, DestinationType, ContentType, TabType> : DestinationConfigurationsContaining where EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable
  • Undocumented

    See more

    Declaration

    Swift

    @MainActor
    public final class DefaultDestinationState<Destination> : StateModeling where Destination : Destinationable
  • A default assistant to be used to configure the presentation of Destination routes. This only adds the the current Destination’s id as the parentID value.

    See more

    Declaration

    Swift

    @MainActor
    public final class DefaultPresentationAssistant<EventType, DestinationType, ContentType> : InterfaceActionConfiguring where EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable
  • Manages state for a Destination’s interface and holds a reference to it.

    See more

    Declaration

    Swift

    @MainActor
    public final class DestinationInterfaceState<Destination> : DestinationStateable where Destination : Destinationable
  • This class holds the internal state of classes conforming to the Destinationable protocol.

    See more

    Declaration

    Swift

    public final class DestinationInternalState<EventType, DestinationType, ContentType, TabType, InteractorType> : DestinationInternalStateable where EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • This is a model used to configure how a Destination is presented or removed. It contains information such as the type of Destination to present, the type of presentation to be made, and the type of content to pass along. They are typically associated with a particular InterfaceAction and used to trigger a new presentation when a user interaction is made with the current UI.

    Destinations has several built-in presentation types which DestinationPresentation supports to enable native SwiftUI and UIKit UI navigation, as well as more complex or custom behavior.

    • navigationStack(type: NavigationPresentationType) This presentation type will add and present a Destination in a navigation stack such as a UINavigationController or SwiftUI’s NavigationStack.
    • tabBar(tab: TabType) This presentation type will present a Destination in the specified tab of a tab bar component, such as a UITabBarController or SwiftUI’s TabView. If no destinationType is present in the DestinationPresentation model, the specified tab will simply be selected, becoming the active tab within the interface.
    • splitView(column: SplitViewColumn) This presentation type will present a Destination in a column of a split view interface, such as a UISplitViewController or SwiftUI’s NavigationSplitView.
    • addToCurrent This presentation type adds a Destination as a child of the currently-presented Destination. Note that this type only works with UIKit and utilizes UIViewController‘s addChild method.
    • replaceRoot This presentation type removes all Destinations that are currently presented and adds a new root Destination. This is useful in use cases such as a user signing out, where you need to remove all the current UI and present a new screen.
    • replaceCurrent This presentation type replaces the currently-presented Destination with a new Destination in system UI components which allow that.
    • sheet(type: SheetPresentationType, options: SheetPresentationOptions?) This presentation type presents (or dismisses) a Destination in a sheet. The options parameter allows you to customize how the sheet is presented, configuring SwiftUI-specific options with a ViewSheetPresentationOptions model and UIKit-specific options with a ControllerSheetPresentationOptions model.
    • destinationPath(path: [DestinationPresentation]) This presentation type presents a path of multiple Destination objects, useful for providing deep linking functionality or building complex state with one event. This presentation could be used for instance to rebuild a navigation stack when resuming a user’s state.
    • custom(presentation: CustomPresentation<DestinationPresentation>) This presentation type enables you to present a custom presentation of a Destination. It can be used to support the presentation of custom UI, as well as system components which Destinations does not directly support. The presentation parameter allows you to use a CustomPresentation model with specialized closures to provide whatever functionality you need.
    See more

    Declaration

    Swift

    @MainActor
    public final class DestinationPresentation<DestinationType, ContentType, TabType> where DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable
    extension DestinationPresentation: Hashable, Equatable
  • A singleton object which contains global options and an internal logger for Destinations. If you wish to interact with this class, please use the shared reference.

    See more

    Declaration

    Swift

    @MainActor
    public final class DestinationsSupport
  • This class holds internal state specific to the GroupedDestinationable protocol.

    See more

    Declaration

    Swift

    public final class GroupDestinationInternalState<DestinationType, ContentType, TabType> : GroupDestinationInternalStateable where DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable
  • Manages state for a Destination’s interface, holding a reference to its associated Destination and a navigator object which manages the state of the interface’s navigation stack.

    See more

    Declaration

    Swift

    @MainActor
    public final class NavigationDestinationInterfaceState<Destination> : NavigationDestinationStateable where Destination : Destinationable
  • This class brings SwiftUI’s NavigationStack into the Destinations ecosystem, handling the state of the stack.

    See more

    Declaration

    Swift

    @MainActor
    public final class DestinationNavigator : DestinationPathNavigating
  • This class coordinates the presentation of a Destination within the SwiftUI framework.

    See more

    Declaration

    Swift

    @MainActor
    public final class DestinationSwiftUICoordinator : NSObject, DestinationSwiftUICoordinating
  • A Destination which represents a SwiftUI View that contains a NavigationSplitView.

    This is a generic Destination that can be used to represent NavigationSplitView implementations in a SwiftUI-based app.

    To implement the NavigationSplitView associated with this Destination and to enable dynamic updating of your NavigationSplitView‘s column, bind these properties from inside each column’s closure using a BindableContainerView.

    Example:

    NavigationSplitView(columnVisibility: $columnVisibility) {
        BindableContainerView(content: $destinationState.destination.currentSidebar)
    } content: {
        BindableContainerView(content: $destinationState.destination.currentContent)
    } detail: {
        BindableContainerView(content: $destinationState.destination.currentDetail)
    }
    
    See more

    Declaration

    Swift

    @MainActor
    public final class NavigationSplitViewDestination<ViewType, EventType, DestinationType, ContentType, TabType, InteractorType> : NavigationSplitViewDestinationable where ViewType : NavigationSplitViewDestinationInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • A Destination class whose associated user interface is a View which contains a NavigationStack.

    This is a generic Destination that can be used to represent most NavigationStack-based Views in a SwiftUI-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class NavigationViewDestination<EventType, ViewType, DestinationType, ContentType, TabType, InteractorType> : NavigatingViewDestinationable where EventType : EventTypeable, ViewType : NavigatingDestinationInterfacing, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • Configures the presentation of a SwiftUI sheet.

    See more

    Declaration

    Swift

    public final class SheetPresentation : SheetPresentationConfiguring
  • A Destination which represents a SwiftUI View which contains a TabView.

    This is a generic Destination that can be used to represent most TabViews in a SwiftUI-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class TabViewDestination<ViewType, EventType, DestinationType, ContentType, TabType, InteractorType> : TabBarViewDestinationable where ViewType : TabBarViewDestinationInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
    extension TabViewDestination: @preconcurrency CustomStringConvertible
  • A Destination class whose associated user interface is a SwiftUI View.

    This is a generic Destination that can be used to represent most Views in a SwiftUI-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class ViewDestination<ViewType, EventType, DestinationType, ContentType, TabType, InteractorType> : ViewDestinationable where ViewType : ViewDestinationInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
    extension ViewDestination: Equatable
    extension ViewDestination: @preconcurrency CustomStringConvertible
  • A concrete Flow class designed to be used to manage Destinations flows within the SwiftUI framework. In most cases creating a custom Flow object is unnecessary, and this class can be used as-is in your SwiftUI-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class ViewFlow<DestinationType, TabType, ContentType> : ViewFlowable, ObservableObject where DestinationType : RoutableDestinations, TabType : TabTypeable, ContentType : ContentTypeable
    extension ViewFlow: DestinationInterfaceCoordinatorDelegate
  • A model that’s used internally to represent tab types in Destinations.

    See more

    Declaration

    Swift

    public final class TabModel<TabType> : Equatable, Hashable where TabType : TabTypeable
    extension TabModel: CustomDebugStringConvertible
  • A Destination class whose associated user interface is a UIViewController.

    This is a generic Destination that can be used to represent most UIViewController subclasses in a UIKit-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class ControllerDestination<ControllerDestinationType, EventType, DestinationType, ContentType, TabType, InteractorType> : ControllerDestinationable where ControllerDestinationType : ControllerDestinationInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
    extension ControllerDestination: Equatable
    extension ControllerDestination: @preconcurrency CustomStringConvertible
  • A concrete Flow class designed to be used to manage Destinations flows within the UIKit framework. In most cases creating a custom Flow object is unnecessary, and this class can be used as-is in your UIKit-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class ControllerFlow<DestinationType, TabType, ContentType> : NSObject, ControllerFlowable, UITabBarControllerDelegate where DestinationType : RoutableDestinations, TabType : TabTypeable, ContentType : ContentTypeable
    extension ControllerFlow: DestinationInterfaceCoordinatorDelegate
  • This class coordinates the presentation of a Destination within the UIKit framework.

    See more

    Declaration

    Swift

    @MainActor
    public final class DestinationUIKitCoordinator : NSObject, DestinationUIKitCoordinating
  • A Destination class whose associated user interface is a UINavigationController.

    This is a generic Destination that can be used to represent most UINavigationController classes in a UIKit-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class NavigationControllerDestination<ControllerDestinationType, EventType, DestinationType, ContentType, TabType, InteractorType> : NavigatingControllerDestinationable where ControllerDestinationType : NavigationControllerDestinationInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
    extension NavigationControllerDestination: Equatable
    extension NavigationControllerDestination: @preconcurrency CustomStringConvertible
  • Undocumented

    See more

    Declaration

    Swift

    @MainActor
    public final class DefaultNavigationController<EventType, DestinationType, ContentType, TabType, InteractorType> : UINavigationController, NavigationControllerDestinationInterfacing where EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • Undocumented

    See more

    Declaration

    Swift

    @MainActor
    public final class DefaultNavigationControllerDestination<EventType, DestinationType, ContentType, TabType, InteractorType> : NavigatingControllerDestinationable where EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • A UISplitViewController subclass which can be used as an interface for a SplitViewControllerDestination.

    See more

    Declaration

    Swift

    @MainActor
    public final class SplitViewController<EventType, DestinationType, ContentType, TabType, InteractorType> : UISplitViewController, SplitViewControllerDestinationInterfacing where EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • A Destination which represents a UIKit UISplitViewController.

    This is a generic Destination that can be used to represent most UISplitViewControllers in a UIKit-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class SplitViewControllerDestination<EventType, DestinationType, ContentType, TabType, InteractorType> : SplitViewControllerDestinationable where EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • Adapts a SwiftUI View for use inside a UIViewController, using a UIHostingController to present it within UIKit.

    See more

    Declaration

    Swift

    @MainActor
    public final class SwiftUIAdapter<Content> : SwiftUIAdaptable where Content : ViewDestinationInterfacing
  • A controller that serves as a container for a SwiftUI View.

    See more

    Declaration

    Swift

    @MainActor
    public final class SwiftUIContainerController<Content> : UIViewController, SwiftUIContainerInterfacing where Content : SwiftUIHostedInterfacing
  • A Destination representing a SwiftUIContainerController instance which presents a SwiftUI View within UIKit.

    See more

    Declaration

    Swift

    @MainActor
    public final class SwiftUIContainerDestination<ViewType, EventType, DestinationType, ContentType, TabType, InteractorType> : SwiftUIContainerDestinationable where ViewType : SwiftUIHostedInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • A state object for a SwiftUI View being hosted within a UIKit interface.

    See more

    Declaration

    Swift

    @MainActor
    public final class SwiftUIHostingState<Content, EventType, DestinationType, ContentType, TabType, InteractorType> : NavigationDestinationStateable where Content : SwiftUIHostedInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable
  • A Destination which represents a UIKit UITabViewController.

    This is a generic Destination that can be used to represent most UITabViewControllers in a UIKit-based app.

    See more

    Declaration

    Swift

    @MainActor
    public final class TabBarControllerDestination<ControllerType, EventType, DestinationType, ContentType, TabType, InteractorType> : TabBarControllerDestinationable where ControllerType : TabBarControllerDestinationInterfacing, EventType : EventTypeable, DestinationType : RoutableDestinations, ContentType : ContentTypeable, TabType : TabTypeable, InteractorType : InteractorTypeable