Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example/FlowPilotExample.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand Down Expand Up @@ -329,7 +329,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_STRICT_CONCURRENCY = complete;
SWIFT_VERSION = 5.0;
SWIFT_VERSION = 6.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
5 changes: 3 additions & 2 deletions Example/Sources/Scenes/Root/First/FirstViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@
import Foundation
import Combine

protocol FirstViewModelRoutingDelegate: AnyObject {
func dismiss()
protocol FirstViewModelRoutingDelegate: AnyObject, Sendable {
@MainActor func dismiss()
func continueLoop() async throws
func showSecondView() async throws
}

@MainActor
final class FirstViewModel: ObservableObject {
var count: Int

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import Foundation
import Combine

protocol ResponseParametersViewModelRoutingDelegate: AnyObject {
func response(with: Bool)
protocol ResponseParametersViewModelRoutingDelegate: AnyObject, Sendable {
@MainActor func response(with: Bool)
}

@MainActor
final class ResponseParametersViewModel: ObservableObject {
weak var routingDelegate: ResponseParametersViewModelRoutingDelegate?

Expand All @@ -28,7 +29,7 @@ final class ResponseParametersViewModel: ObservableObject {
func send(action: Action) async {
switch action {
case .save:
await routingDelegate?.response(with: value)
routingDelegate?.response(with: value)
}
}
}
2 changes: 1 addition & 1 deletion Example/Sources/Scenes/Root/RootViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import Foundation
import Combine

protocol RootViewModelRoutingDelegate: AnyObject {
protocol RootViewModelRoutingDelegate: AnyObject, Sendable {
func showFirst() async throws
func showSecondView() async throws
func showThirdModal() async throws
Expand Down
3 changes: 2 additions & 1 deletion Example/Sources/Scenes/Root/Second/SecondViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import Foundation
import Combine

protocol SecondViewModelRoutingDelegate: AnyObject {
protocol SecondViewModelRoutingDelegate: AnyObject, Sendable {
func dismiss() async
}

@MainActor
final class SecondViewModel: ObservableObject {
weak var routingDelegate: SecondViewModelRoutingDelegate?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import Foundation
import Combine

protocol ThirdModalViewModelRoutingDelegate: AnyObject {
protocol ThirdModalViewModelRoutingDelegate: AnyObject, Sendable {
func dismiss() async
}

@MainActor
final class ThirdModalViewModel: ObservableObject {
weak var routingDelegate: ThirdModalViewModelRoutingDelegate?

Expand Down
61 changes: 30 additions & 31 deletions Package.resolved

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Sources/FlowPilot/AnyRouter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ final public class AnyRouter: Router {
- Note: Both `presentAction` and `dismissAction` closures are stored as properties to be used later when presenting or dismissing a view controller. The closures should take into account the platform-specific APIs when performing their respective actions.
*/
@inlinable
init(presentAction: @escaping (PlatformViewController, Bool) -> Void,
dismissAction: @escaping (Bool, (() -> Void)?) -> Void,
dismissRouterAction: @escaping (Bool, (() -> Void)?) -> Void) {
init(presentAction: @escaping @MainActor (PlatformViewController, Bool) -> Void,
dismissAction: @escaping @MainActor (Bool, (() -> Void)?) -> Void,
dismissRouterAction: @escaping @MainActor (Bool, (() -> Void)?) -> Void) {
self.presentAction = presentAction
self.dismissAction = dismissAction
self.dismissRouterAction = dismissRouterAction
Expand Down
9 changes: 8 additions & 1 deletion Sources/FlowPilot/Router.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Combine

/// A protocol that defines the common behavior of a router that can present and dismiss view controllers.
@available(macOS 10.15, *)
@MainActor
public protocol Router: AnyObject {
/// Presents a view controller.
///
Expand Down Expand Up @@ -53,7 +54,13 @@ public extension Router {
@inlinable
@MainActor
func eraseToAnyRouter() -> AnyRouter {
AnyRouter(presentAction: present(_:animated:), dismissAction: dismiss(animated:completion:), dismissRouterAction: dismissRouter(animated:completion:))
AnyRouter(presentAction: { viewController, animated in
self.present(viewController, animated: animated)
}, dismissAction: { animated, completion in
self.dismiss(animated: animated, completion: completion)
}, dismissRouterAction: { animated, completion in
self.dismissRouter(animated: animated, completion: completion)
})
}
}

Expand Down
Loading