Skip to content

Commit

Permalink
Merge pull request #2 from lukepistrol/fix/sendable
Browse files Browse the repository at this point in the history
Fixes #1: Sendable conformance for Value
  • Loading branch information
lukepistrol authored Sep 20, 2023
2 parents 714fd78 + 2e61b9d commit 17e002b
Show file tree
Hide file tree
Showing 14 changed files with 568 additions and 5 deletions.
6 changes: 4 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ let package = Package(
products: [
.library(
name: "TaskTrigger",
targets: ["TaskTrigger"]),
targets: ["TaskTrigger"]
),
],
targets: [
.target(
name: "TaskTrigger"),
name: "TaskTrigger"
),
]
)
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Attach async tasks to SwiftUI views using a trigger mechanism. See [this](#the-s
## Table Of Contents

- [Usage](#usage)
- [Documentation](#documentation)
- [Overview](#overview)
- [The Problem](#the-problem)
- [The Solution](#the-solution)
Expand All @@ -23,6 +24,12 @@ dependencies: [

Make sure to `import TaskTrigger` in any location you'd want to use it.

## Documentation

The documentation is available [here](https://lukepistrol.github.io/TaskTrigger/documentation/tasktrigger).

You can also have a look at the [sample project](https://github.com/lukepistrol/TaskTrigger/tree/main/TaskTriggerDemo/TaskTriggerDemo)

## Overview

When using Swift's structured concurrency in SwiftUI it is good practice to
Expand Down
2 changes: 1 addition & 1 deletion Sources/TaskTrigger/TaskTrigger.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import SwiftUI

public struct TaskTrigger<Value: Equatable>: Equatable {
public struct TaskTrigger<Value: Equatable>: Equatable where Value: Sendable {

internal enum TaskState<T: Equatable>: Equatable {
case none
Expand Down
2 changes: 1 addition & 1 deletion Sources/TaskTrigger/TaskTriggerViewModifier.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import SwiftUI

struct TaskTriggerViewModifier<Value: Equatable>: ViewModifier {
struct TaskTriggerViewModifier<Value: Equatable>: ViewModifier where Value: Sendable {

typealias Action = @Sendable (_ value: Value) async -> Void

Expand Down
2 changes: 1 addition & 1 deletion Sources/TaskTrigger/View+Task.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public extension View {
func task<Value: Equatable>(
_ trigger: Binding<TaskTrigger<Value>>,
_ action: @escaping @Sendable @MainActor (_ value: Value) async -> Void
) -> some View {
) -> some View where Value: Sendable {
modifier(TaskTriggerViewModifier(trigger: trigger, action: action))
}

Expand Down
Loading

0 comments on commit 17e002b

Please sign in to comment.