Protocols

The following protocols are available globally.

  • This protocol represents a datasource Interactor actor. These datasources can be used to provide items to a Destination’s view interface.

    See more

    Declaration

    Swift

    public protocol AsyncDatasourceable<ResultData> : AsyncInteractable
  • This protocol represents an Interactor actor. Interactors provide an interface to perform some business logic, often acting as a datasource by interfacing with an API, handling system APIs, or some other self-contained work.

    See more

    Declaration

    Swift

    public protocol AsyncInteractable<Request, ResultData> : Interactable, Actor
  • This protocol represents a delegate object that provides status updates during the retrieval of items by a Datasourceable object.

    See more

    Declaration

    Swift

    public protocol DatasourceItemsProviderStatusDelegate : AnyObject
  • This protocol represents a datasource interactor. These datasources can be used to provide items to a Destination’s view interface.

    See more

    Declaration

    Swift

    public protocol Datasourceable<ResultData> : AnyObject, Interactable
  • This protocol represents an object that holds Destination presentation objects.

    See more

    Declaration

    Swift

    public protocol DestinationConfigurationsContaining<UserInteractionType, DestinationType, TabType, PresentationConfiguration, ContentType>
  • This protocol defines methods that an object should implement to receive updates from DestinationInterfaceCoordinator objects.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationInterfaceCoordinatorDelegate : AnyObject
  • This abstract protocol represents an object that coordinates the presentation of a Destination within a UI framework.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationInterfaceCoordinating
  • A protocol representing a user interface object that is handled by Destinations. This is typically a View in SwiftUI or a UIViewController in UIKit.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationInterfacing<PresentationConfiguration>
  • This protocol represents a Destination navigator path object. It should be implemented to allow for system-level navigation stacks like SwiftUI’s NavigationStack into the Destinations ecosystem, which the DestinationNavigator class implements.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationPathNavigating : AnyObject
  • This protocol represents a configuration object for the presentation of a Destination. Classes adopting this protocol should handle the presentation of Destinations within the system UI framework being used.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationPresentationConfiguring<DestinationType, TabType, ContentType> : AnyObject
  • This is an abstract protocol which defines Provider classes which build and provide new Destination objects, including their interface elements. Each Provider should be responsible for building a unique Destination and its associated interface.

    Note

    Adopt SDK-specific protocols like ViewDestinationProviding or ControllerDestinationProviding when creating your own provider classes.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationProviding
  • This protocol represents an interface’s state object which holds a reference to its associated Destination.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationStateable<Destination> : AnyObject
  • This protocol represents a Destination in the Destinations ecosystem.

    A Destination represents a unique area in an app which can be navigated to by the user. In SwiftUI this is typically a fullscreen View object, and in UIKit it’s a UIViewController class or subclass, but it can also be a group of Destinations like a TabBar or a carousel. Destinations hold references to the UI element they’re associated with, but they don’t handle the particulars of laying out elements on the screen. Instead, the role of Destination objects in the ecosystem is to send and receive messages and datasource requests on behalf of their UI, such as passing on a message to trigger an action when a user taps a button.

    In most cases you should be able to use the provided ViewDestination or ControllerDestination classes for SwiftUI or UIKit apps respectively. They are customized to a particular Destination through generic arguments. To handle presentation requests that require specialized configuration or need to handle content models, you can create custom assistants which conform to the InterfaceActionConfiguring protocol. To handle requests to an interactor, you can create assistants which conform to the InteractorAssisting protocol. There are more specific classes to support interfaces like TabBars, but you can also use your own Destination classes by conforming to ViewDestinationable or ControllerDestinationable if you should need custom functionality or just want to avoid using generics.

    There is a two-way connection between a Destination and its interface which is handled by a DestinationStateable-conforming object. Destinations comes with a DestinationInterfaceState object which can be used for this purpose, though you can create your own class if you’d like to store other state in it. When a Destination is removed from the ecosystem, cleanup is done internally to ensure no retain cycles occur.

    See more

    Declaration

    Swift

    @MainActor
    public protocol Destinationable<PresentationConfiguration> : AnyObject, Identifiable
  • This protocol represents Flow objects which coordinate routing, navigation, and the management of Destination objects as a user moves through an app’s interface.

    Flows manage the creation, appearance, and removal of Destinations as a user navigates through the app. They are the single source of truth for what Destinations currently exist in the ecosystem. Typically you don’t interact with them directly after they’ve been configured. In most cases you can use one of the provided ViewFlow or ControllerFlow classes for SwiftUI and UIKit apps respectively.

    See more

    Declaration

    Swift

    @MainActor
    public protocol Flowable : AnyObject, Observable
  • This protocol represents a type of Destination which manages child Destinations, such as a NavigationStack in SwiftUI.

    See more

    Declaration

    Swift

    @MainActor
    public protocol GroupedDestinationable<PresentationConfiguration> : AnyObject
  • This protocol represents an Interactor object. Interactors provide an interface to perform some business logic, often acting as a datasource by interfacing with an API, handling system APIs, or some other self-contained work.

    The concept of Interactors comes from Clean Swift, used in its architecture as a way to move logic and datasource management out of view controllers. In Destinations, the Interactable protocol represents Interactor objects which provide an interface to perform some logic or data request, typically by interfacing with an backend API, handling system APIs, or some other self-contained work. Datasourceable inherits from this protocol and should be used for objects which specifically represent a datasource of some kind. There are also Actor-based async versions of these protocols available.

    Though requests to Interactors can be made using a Destination’s performRequest method, in general one should use the performInterfaceAction method. This abstracts the specific implementation details of an interactor away from the interface and lets it focus on making requests through a standardized request.

    The recommended way is to assign a user interaction type to your request and using an InteractorAssisting-conforming assistant to configure the request, leaving the Destination’s interface free of associated business logic.

    Interactors are typically created by Destination providers and stored in the Destination. Like with presentations of new Destinations, Interactor requests are associated with a particular InterfaceAction object and are represented by an InteractorConfiguration model object. Action types for each Interactor are defined as enums, keeping Interactor-specific knowledge out of the interface.

    Here the configuration model for the interface action is being assigned to a “moreButton” user interaction type when the Destination’s provider is created:

      let moreButtonConfiguration = InteractorConfiguration<ColorsListProvider.InteractorType, ColorsDatasource>(interactorType: .colors, actionType: .paginate)
      let colorsListProvider = ColorsListProvider(presentationsData: [.color: colorSelection],
                                                  interactorsData: [.moreButton: moreButtonConfiguration])
    

    And here is that user interaction type being called a Destination’s interface after a user’s tap on a UI element. Note that performInterfaceAction can throw and the Destination method handleThrowable automatically handles that for you, logging any errors to the console with the built-in Logger class.

     destination().handleThrowable { [weak self] in
        try self?.destination().performInterfaceAction(interactionType: .moreButton)
     }
    

    If it’s necessary, you can always make a request to a Destination’s Interactor directly:

     Task {
        let request = ColorsRequest(action: .paginate, numColorsToRetrieve: 5)
    
        let result = await destination().performRequest(interactor: .colors, request: request)
        await handleColorsResult(result: result)
     }
    
    See more

    Declaration

    Swift

    public protocol Interactable<Request, ResultData>
  • This protocol represents an assistant which helps a Destination make requests of an interactor. Concrete assistants conforming to this protocol should handle requests for a specific interactor type.

    See more

    Declaration

    Swift

    @MainActor
    public protocol InteractorAssisting<Destination>
  • This protocol represents a model which configures how an interactor is used with a Destination.

    See more

    Declaration

    Swift

    public protocol InteractorConfiguring<InteractorType>
  • This protocol represents an Interactor configuration model which defines a request to perform an action.

    See more

    Declaration

    Swift

    public protocol InteractorRequestConfiguring : Sendable
  • This protocol represents an enum which defines types of actions for a particular Interactor.

    Declaration

    Swift

    public protocol InteractorRequestActionTypeable : Hashable
  • This protocol represents an assistant which configures an InterfaceAction object that should present a Destination. This is typically used in conjunction with a Destination such as ControllerDestination or ViewDestination.

    See more

    Declaration

    Swift

    @MainActor
    public protocol InterfaceActionConfiguring<UserInteractionType, DestinationType, ContentType>
  • This protocol represents an interface’s state object, 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 protocol NavigationDestinationStateable<Destination> : DestinationStateable
  • This protocol represents an object that coordinates the presentation of a Destination within the SwiftUI framework.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationSwiftUICoordinating : DestinationInterfaceCoordinating
  • A protocol representing a SwiftUI View that is associated with a Destination and contains a NavigationStack.

    See more

    Declaration

    Swift

    @MainActor
    public protocol NavigatingDestinationInterfacing : ViewDestinationInterfacing where Self.DestinationState : NavigationDestinationStateable
  • This protocol represents a type of Destination which manages a SwiftUI NavigationStack.

    See more

    Declaration

    Swift

    @MainActor
    public protocol NavigatingViewDestinationable<PresentationConfiguration> : GroupedDestinationable, ViewDestinationable where Self.ViewType : NavigatingDestinationInterfacing
  • A protocol defining a SwiftUI View which handles a NavigationSplitView and conforms to Destinations.

    Declaration

    Swift

    @MainActor
    public protocol NavigationSplitViewDestinationInterfacing : ViewDestinationInterfacing where Self.Destination : NavigationSplitViewDestinationable
  • This protocol represents a Destination whose interface View handles a NavigationSplitView.

    See more

    Declaration

    Swift

    @MainActor
    public protocol NavigationSplitViewDestinationable<PresentationConfiguration> : GroupedDestinationable, ViewDestinationable where Self.ViewType : NavigationSplitViewDestinationInterfacing
  • This protocol configures the presentation of a SwiftUI sheet.

    See more

    Declaration

    Swift

    public protocol SheetPresentationConfiguring : Equatable, Identifiable
  • This protocol represents a View that supports presenting a SwiftUI sheet via its SheetPresenter object.

    To present a sheet using Destinations, simply have your View adopt this protocol, add a ViewModifier for the sheetPresenter (.modifier(sheetPresenter)), and present a Destination with a presentationType of .sheet(type: .present).

    See more

    Declaration

    Swift

    @MainActor
    public protocol SheetPresenting : ViewDestinationInterfacing
  • This protocol represents a model used for presenting a SwiftUI sheet element.

    See more

    Declaration

    Swift

    public protocol Sheetable : Identifiable
  • A protocol defining a SwiftUI View which handles a TabView and conforms to Destinations.

    See more

    Declaration

    Swift

    @MainActor
    public protocol TabBarViewDestinationInterfacing<TabType> : TabBarDestinationInterfacing, ViewDestinationInterfacing where Self.Destination : TabBarViewDestinationable, Self.TabType == Self.Destination.TabType
  • This protocol represents a Destination whose interface view handles a TabBar.

    See more

    Declaration

    Swift

    @MainActor
    public protocol TabBarViewDestinationable<PresentationConfiguration, TabType> : GroupedDestinationable, ViewDestinationable where Self.TabType == Self.ViewType.TabType, Self.ViewType : TabBarViewDestinationInterfacing
  • A protocol representing a SwiftUI View that is associated with a Destination.

    See more

    Declaration

    Swift

    @MainActor
    public protocol ViewDestinationInterfacing : DestinationInterfacing, View where Self.Destination : ViewDestinationable
  • This protocol represents objects which construct and provide ViewDestinationable objects, including their associated interface elements. Provider objects which conform to this protocol should build discrete Destinations based on their specific destination type.

    See more

    Declaration

    Swift

    @MainActor
    public protocol ViewDestinationProviding<PresentationConfiguration> : DestinationProviding where Self.PresentationType == DestinationPresentationType<Self.PresentationConfiguration>
  • This protocol represents a Destination which is associated with a SwiftUI View.

    See more

    Declaration

    Swift

    @MainActor
    public protocol ViewDestinationable<PresentationConfiguration> : Destinationable where Self.PresentationType == DestinationPresentationType<Self.PresentationConfiguration>
  • This protocol represents a Flow which coordinates routing and navigation as a user moves through a SwiftUI-based app.

    See more

    Declaration

    Swift

    @MainActor
    public protocol ViewFlowable<PresentationConfiguration> : Flowable where Self.InterfaceCoordinator == DestinationSwiftUICoordinator, Self.PresentationConfiguration == DestinationPresentation<Self.DestinationType, Self.ContentType, Self.TabType>, Self.PresentationType == DestinationPresentationType<DestinationPresentation<Self.DestinationType, Self.ContentType, Self.TabType>>
  • This protocol represents a View that manages a TabBar.

    See more

    Declaration

    Swift

    @MainActor
    public protocol TabBarDestinationInterfacing : DestinationInterfacing
  • This protocol represents an enum describing the types of content that are able to be sent through Destinations.

    Declaration

    Swift

    public protocol ContentTypeable : Equatable
  • This protocol represents an enum which defines Destination presentation types.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationPresentationTypeable
  • This protocol represents an enum which defines Interactors in the app. It can be scoped to an individual Destination.

    Declaration

    Swift

    public protocol InteractorTypeable : Hashable
  • This protocol represents an enum which defines Destination types for an app which can be routed to.

    See more

    Declaration

    Swift

    public protocol RoutableDestinations : Hashable
  • A protocol representing an enum which defines tabs for a tab bar interface.

    See more

    Declaration

    Swift

    public protocol TabTypeable : CaseIterable, Hashable where Self.AllCases : RandomAccessCollection
  • This protocol represents enums which define user interaction types for a Destination’s interface.

    See more

    Declaration

    Swift

    public protocol UserInteractionTypeable : Hashable
  • A protocol representing UIViewControllers which conform to Destinations

    See more

    Declaration

    Swift

    @MainActor
    public protocol ControllerDestinationInterfacing : UIViewController, DestinationInterfacing
  • This protocol represents a UINavigationController that is associated with a Destination.

    Declaration

    Swift

    @MainActor
    public protocol NavigationControllerDestinationInterfacing : UINavigationController, ControllerDestinationInterfacing
  • This protocol represents objects which construct and provide ControllerDestinationable objects, including their associated interface elements. Provider objects which conform to this protocol should build discrete Destinations based on their specific destination type.

    See more

    Declaration

    Swift

    @MainActor
    public protocol ControllerDestinationProviding<PresentationConfiguration> : DestinationProviding where Self.PresentationType == DestinationPresentationType<Self.PresentationConfiguration>
  • This protocol represents a Destination which is associated with a UIViewController.

    See more

    Declaration

    Swift

    @MainActor
    public protocol ControllerDestinationable<PresentationConfiguration> : Destinationable where Self.PresentationType == DestinationPresentationType<Self.PresentationConfiguration>
  • This protocol represents a Flow which coordinates routing and navigation as a user moves through a UIKit-based app.

    See more

    Declaration

    Swift

    @MainActor
    public protocol ControllerFlowable<PresentationConfiguration> : Flowable where Self.InterfaceCoordinator == DestinationUIKitCoordinator, Self.PresentationConfiguration == DestinationPresentation<Self.DestinationType, Self.ContentType, Self.TabType>, Self.PresentationType == DestinationPresentationType<DestinationPresentation<Self.DestinationType, Self.ContentType, Self.TabType>>
  • This protocol represents an object that coordinates the presentation of a Destination within the UIKit framework.

    See more

    Declaration

    Swift

    @MainActor
    public protocol DestinationUIKitCoordinating : DestinationInterfaceCoordinating, UINavigationControllerDelegate
  • This protocol represents a Destination whose interface is a UINavigationController.

    See more

    Declaration

    Swift

    @MainActor
    public protocol NavigatingControllerDestinationable<PresentationConfiguration> : ControllerDestinationable, GroupedDestinationable where Self.ControllerType : UINavigationController
  • A protocol representing a UISplitViewController class which conforms to Destinations.

    Declaration

    Swift

    @MainActor
    public protocol SplitViewControllerDestinationInterfacing : UISplitViewController, ControllerDestinationInterfacing where Self.Destination : SplitViewControllerDestinationable
  • This protocol represents a Destination whose interface is a UISplitViewController.

    See more

    Declaration

    Swift

    @MainActor
    public protocol SplitViewControllerDestinationable<PresentationConfiguration> : ControllerDestinationable, GroupedDestinationable where Self.ControllerType : UISplitViewController
  • This protocol represents an object that adapts a SwiftUI View for use inside a UIViewController.

    See more

    Declaration

    Swift

    @MainActor
    public protocol SwiftUIAdaptable
  • This protocol represents a controller that serves as a container for a SwiftUI View.

    See more

    Declaration

    Swift

    @MainActor
    public protocol SwiftUIContainerInterfacing<Content> : ControllerDestinationInterfacing
  • This protocol represents a SwiftUI View that is hosted by a container controller within UIKit.

    See more

    Declaration

    Swift

    @MainActor
    public protocol SwiftUIHostedInterfacing : ViewDestinationInterfacing
  • A protocol representing a UITabBarController class which conforms to Destinations.

    See more

    Declaration

    Swift

    @MainActor
    public protocol TabBarControllerDestinationInterfacing<TabType> : UITabBarController, ControllerDestinationInterfacing, TabBarDestinationInterfacing where Self.Destination : TabBarControllerDestinationable, Self.TabType == Self.Destination.TabType
  • This protocol represents a Destination whose interface is a UITabBarController.

    See more

    Declaration

    Swift

    @MainActor
    public protocol TabBarControllerDestinationable<PresentationConfiguration, TabType> : ControllerDestinationable, GroupedDestinationable where Self.ControllerType : TabBarControllerDestinationInterfacing, Self.TabType == Self.ControllerType.TabType