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 MainActor to KeyView initializer #36

Merged
merged 1 commit into from
Feb 29, 2024
Merged
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
15 changes: 9 additions & 6 deletions Sources/StreamDeckKit/Layout/StreamDeckKeyView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,25 @@ import SwiftUI

public struct StreamDeckKeyView<Content: View>: View {

public typealias KeyAction = @MainActor (_ isPressed: Bool) -> Void
public typealias ContentProvider = @MainActor () -> Content

@Environment(\.streamDeckViewContext) var context

let action: @MainActor (Bool) -> Void
@ViewBuilder let content: @MainActor () -> Content
let action: KeyAction
@ViewBuilder let content: ContentProvider

public init(
action: @escaping (Bool) -> Void,
@ViewBuilder content: @escaping () -> Content
action: @escaping KeyAction,
@ViewBuilder content: @escaping ContentProvider
) {
self.action = action
self.content = content
}

public init(
action: @escaping () -> Void,
@ViewBuilder content: @escaping () -> Content
action: @escaping @MainActor () -> Void,
@ViewBuilder content: @escaping ContentProvider
) {
self.init(
action: { if $0 { action() } },
Expand Down