Skip to content

Instantly share code, notes, and snippets.

@rnapier
rnapier / AsyncFutureTests.swift
Last active January 11, 2025 19:54
AsyncFuture
import Testing
import Combine
// From https://stackoverflow.com/questions/78892734/getting-task-isolated-value-of-type-async-passed-as-a-strongly-trans/78899940#78899940
public final class AsyncFuture<Output, Failure: Error>: Publisher, Sendable {
public typealias Promise = @Sendable (Result<Output, Failure>) -> Void
private let work: @Sendable (@escaping Promise) async -> Void
public init(_ work: @Sendable @escaping (@escaping Promise) async -> Void) {