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 moreDeclaration
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 moreDeclaration
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
See moreDatasourceable
object.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 moreDeclaration
Swift
public protocol Datasourceable<ResultData> : AnyObject, Interactable
-
This protocol represents an object that holds Destination presentation objects.
See moreDeclaration
Swift
public protocol DestinationConfigurationsContaining<UserInteractionType, DestinationType, TabType, PresentationConfiguration, ContentType>
-
This protocol defines methods that an object should implement to receive updates from
See moreDestinationInterfaceCoordinator
objects.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 moreDeclaration
Swift
@MainActor public protocol DestinationInterfaceCoordinating
-
A protocol representing a user interface object that is handled by Destinations. This is typically a
See moreView
in SwiftUI or aUIViewController
in UIKit.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
See moreNavigationStack
into the Destinations ecosystem, which theDestinationNavigator
class implements.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 moreDeclaration
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
orControllerDestinationProviding
when creating your own provider classes.Declaration
Swift
@MainActor public protocol DestinationProviding
-
This protocol represents an interface’s state object which holds a reference to its associated Destination.
See moreDeclaration
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 aUIViewController
class or subclass, but it can also be a group of Destinations like aTabBar
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
orControllerDestination
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 theInterfaceActionConfiguring
protocol. To handle requests to an interactor, you can create assistants which conform to theInteractorAssisting
protocol. There are more specific classes to support interfaces like TabBars, but you can also use your own Destination classes by conforming toViewDestinationable
orControllerDestinationable
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
See moreDestinationStateable
-conforming object. Destinations comes with aDestinationInterfaceState
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.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
See moreViewFlow
orControllerFlow
classes for SwiftUI and UIKit apps respectively.Declaration
Swift
@MainActor public protocol Flowable : AnyObject, Observable
-
This protocol represents a type of Destination which manages child Destinations, such as a
See moreNavigationStack
in SwiftUI.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 theperformInterfaceAction
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 anInteractorConfiguration
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 methodhandleThrowable
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:
See moreTask { let request = ColorsRequest(action: .paginate, numColorsToRetrieve: 5) let result = await destination().performRequest(interactor: .colors, request: request) await handleColorsResult(result: result) }
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 moreDeclaration
Swift
@MainActor public protocol InteractorAssisting<Destination>
-
This protocol represents a model which configures how an interactor is used with a Destination.
See moreDeclaration
Swift
public protocol InteractorConfiguring<InteractorType>
-
This protocol represents an Interactor configuration model which defines a request to perform an action.
See moreDeclaration
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
See moreInterfaceAction
object that should present a Destination. This is typically used in conjunction with a Destination such asControllerDestination
orViewDestination
.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 moreDeclaration
Swift
@MainActor public protocol NavigationDestinationStateable<Destination> : DestinationStateable
-
This protocol represents an object that coordinates the presentation of a Destination within the SwiftUI framework.
See moreDeclaration
Swift
@MainActor public protocol DestinationSwiftUICoordinating : DestinationInterfaceCoordinating
-
A protocol representing a SwiftUI
See moreView
that is associated with a Destination and contains aNavigationStack
.Declaration
Swift
@MainActor public protocol NavigatingDestinationInterfacing : ViewDestinationInterfacing where Self.DestinationState : NavigationDestinationStateable
-
This protocol represents a type of Destination which manages a SwiftUI
See moreNavigationStack
.Declaration
Swift
@MainActor public protocol NavigatingViewDestinationable<PresentationConfiguration> : GroupedDestinationable, ViewDestinationable where Self.ViewType : NavigatingDestinationInterfacing
-
A protocol defining a SwiftUI
View
which handles aNavigationSplitView
and conforms to Destinations.Declaration
Swift
@MainActor public protocol NavigationSplitViewDestinationInterfacing : ViewDestinationInterfacing where Self.Destination : NavigationSplitViewDestinationable
-
This protocol represents a Destination whose interface
See moreView
handles aNavigationSplitView
.Declaration
Swift
@MainActor public protocol NavigationSplitViewDestinationable<PresentationConfiguration> : GroupedDestinationable, ViewDestinationable where Self.ViewType : NavigationSplitViewDestinationInterfacing
-
This protocol configures the presentation of a SwiftUI sheet.
See moreDeclaration
Swift
public protocol SheetPresentationConfiguring : Equatable, Identifiable
-
This protocol represents a
View
that supports presenting a SwiftUI sheet via itsSheetPresenter
object.To present a sheet using Destinations, simply have your
See moreView
adopt this protocol, add aViewModifier
for thesheetPresenter
(.modifier(sheetPresenter)
), and present a Destination with apresentationType
of.sheet(type: .present)
.Declaration
Swift
@MainActor public protocol SheetPresenting : ViewDestinationInterfacing
-
This protocol represents a model used for presenting a SwiftUI sheet element.
See moreDeclaration
Swift
public protocol Sheetable : Identifiable
-
A protocol defining a SwiftUI
See moreView
which handles aTabView
and conforms to Destinations.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
See moreTabBar
.Declaration
Swift
@MainActor public protocol TabBarViewDestinationable<PresentationConfiguration, TabType> : GroupedDestinationable, ViewDestinationable where Self.TabType == Self.ViewType.TabType, Self.ViewType : TabBarViewDestinationInterfacing
-
A protocol representing a SwiftUI
See moreView
that is associated with a Destination.Declaration
Swift
@MainActor public protocol ViewDestinationInterfacing : DestinationInterfacing, View where Self.Destination : ViewDestinationable
-
This protocol represents objects which construct and provide
See moreViewDestinationable
objects, including their associated interface elements. Provider objects which conform to this protocol should build discrete Destinations based on their specific destination type.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
See moreView
.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 moreDeclaration
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
See moreView
that manages a TabBar.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 moreDeclaration
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 moreDeclaration
Swift
public protocol RoutableDestinations : Hashable
-
A protocol representing an enum which defines tabs for a tab bar interface.
See moreDeclaration
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 moreDeclaration
Swift
public protocol UserInteractionTypeable : Hashable
-
A protocol representing UIViewControllers which conform to Destinations
See moreDeclaration
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
See moreControllerDestinationable
objects, including their associated interface elements. Provider objects which conform to this protocol should build discrete Destinations based on their specific destination type.Declaration
Swift
@MainActor public protocol ControllerDestinationProviding<PresentationConfiguration> : DestinationProviding where Self.PresentationType == DestinationPresentationType<Self.PresentationConfiguration>
-
This protocol represents a Destination which is associated with a
See moreUIViewController
.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 moreDeclaration
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 moreDeclaration
Swift
@MainActor public protocol DestinationUIKitCoordinating : DestinationInterfaceCoordinating, UINavigationControllerDelegate
-
This protocol represents a Destination whose interface is a
See moreUINavigationController
.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
See moreUISplitViewController
.Declaration
Swift
@MainActor public protocol SplitViewControllerDestinationable<PresentationConfiguration> : ControllerDestinationable, GroupedDestinationable where Self.ControllerType : UISplitViewController
-
This protocol represents an object that adapts a SwiftUI
See moreView
for use inside aUIViewController
.Declaration
Swift
@MainActor public protocol SwiftUIAdaptable
-
This protocol represents a controller that serves as a container for a SwiftUI
See moreView
.Declaration
Swift
@MainActor public protocol SwiftUIContainerInterfacing<Content> : ControllerDestinationInterfacing
-
This protocol represents a SwiftUI
See moreView
that is hosted by a container controller within UIKit.Declaration
Swift
@MainActor public protocol SwiftUIHostedInterfacing : ViewDestinationInterfacing
-
A protocol representing a
See moreUITabBarController
class which conforms to Destinations.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
See moreUITabBarController
.Declaration
Swift
@MainActor public protocol TabBarControllerDestinationable<PresentationConfiguration, TabType> : ControllerDestinationable, GroupedDestinationable where Self.ControllerType : TabBarControllerDestinationInterfacing, Self.TabType == Self.ControllerType.TabType