Skip to content
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
5 changes: 3 additions & 2 deletions Sources/ViewScope/VisibilityScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ public struct VisibilityScope {
priority: TaskPriority = .userInitiated,
operation: sending @escaping @isolated(any) () async -> Void
) {
guard bindCount > 0 else { return }
enqueue(Task(priority: priority, operation: operation))
}

Expand Down Expand Up @@ -132,6 +133,7 @@ public struct VisibilityScope {
priority: TaskPriority = .userInitiated,
operation: sending @escaping () async -> Void
) {
guard bindCount > 0 else { return }
enqueue(Task(executorPreference: taskExecutor, priority: priority, operation: operation))
}

Expand All @@ -149,6 +151,7 @@ public struct VisibilityScope {
priority: TaskPriority = .userInitiated,
operation: sending @escaping () async -> Void
) {
guard bindCount > 0 else { return }
enqueue(Task(executorPreference: taskExecutor, priority: priority, operation: operation), with: id)
}

Expand Down Expand Up @@ -179,15 +182,13 @@ public struct VisibilityScope {
private mutating func enqueue(
_ task: Task<Void, Never>
) {
guard bindCount > 0 else { return }
tasks.append(task)
}

private mutating func enqueue(
_ task: Task<Void, Never>,
with id: some Hashable
) {
guard bindCount > 0 else { return }
keyed[id]?.cancel()
keyed[id] = task
}
Expand Down