Skip to content
This repository was archived by the owner on Jan 4, 2026. It is now read-only.
This repository was archived by the owner on Jan 4, 2026. It is now read-only.

Why so overengineered? Am I missing something? #2

@ursusursus

Description

@ursusursus

I get this is a demo but why not simply use the Future builder?

func TaskPublisher<T>(closure: () async throws -> T)  -> AnyPublisher<T, Error> {
    Deferred {
        Future { emitter in
            Task {
                do {
                    let result = try await closure()
                    emitter(success(result))
                } catch {
                    emitter(error(error))
                }
            }
        }
    }
}

am I missing something?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions