Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit @mainactor to NavigationLink initializer #3430

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
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
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,14 @@ extension DependencyValues {

private enum ScreenshotsKey: DependencyKey {
static let liveValue: @Sendable () async -> AsyncStream<Void> = {
AsyncStream(
NotificationCenter.default
.notifications(named: UIApplication.userDidTakeScreenshotNotification)
.map { _ in }
)
AsyncStream { (continuation: AsyncStream<Void>.Continuation) -> Void in
Task {
for await _ in NotificationCenter.default.notifications(named: UIApplication.userDidTakeScreenshotNotification) {
continuation.yield()
}
continuation.finish()
}
}
chrisjrex marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,9 @@ extension NavigationLink where Destination == Never {
/// - state: An optional value to present. When the user selects the link, SwiftUI stores a
/// copy of the value. Pass a `nil` value to disable the link.
/// - label: A label that describes the view that this link presents.
#if compiler(>=6)
@MainActor
#endif
public init<P, L: View>(
state: P?,
@ViewBuilder label: () -> L,
Expand Down Expand Up @@ -266,6 +269,9 @@ extension NavigationLink where Destination == Never {
/// presents.
/// - state: An optional value to present. When the user selects the link, SwiftUI stores a
/// copy of the value. Pass a `nil` value to disable the link.
#if compiler(>=6)
@MainActor
#endif
public init<P>(
_ titleKey: LocalizedStringKey, state: P?, fileID: StaticString = #fileID, line: UInt = #line
)
Expand All @@ -286,6 +292,9 @@ extension NavigationLink where Destination == Never {
/// - title: A string that describes the view that this link presents.
/// - state: An optional value to present. When the user selects the link, SwiftUI stores a
/// copy of the value. Pass a `nil` value to disable the link.
#if compiler(>=6)
@MainActor
#endif
@_disfavoredOverload
public init<S: StringProtocol, P>(
_ title: S, state: P?, fileID: StaticString = #fileID, line: UInt = #line
Expand Down