profile
viewpoint
David Bou boudavid @Marmelapp Paris

Gpinchon/RT42 1

Ray Tracer de l'école 42

boudavid/swift-composable-architecture 0

A library for building applications in a consistent and understandable way, with composition, testing, and ergonomics in mind.

issue commentpointfreeco/swift-composable-architecture

fireAndForget Environment Side Effect

Hey @wendyliga,

I'm just curious why do you need to use .fireAndForget in that case ? Isn't it better to have a <Success, Failure> in case the network request fails ?

I have a similar case where I need to delete something on the backend and I just care about whether the request succeeded or failed.

// Success and Failure are just empty structs.
func delete(id: String) -> Effect<Success, Failure> {
    var request = URLRequest(url: URL(string: "path/to/delete/something/\(id)")!)

    request.httpMethod = "DELETE"
    return URLSession.shared
        .dataTaskPublisher(for: request)
        .map { _, _ in Success() }
        .mapError { _ in Failure() }
        .eraseToEffect()
}

Is this helpful ?

By the way, I think these kind of questions are better suited for the forums. 😃

wendyliga

comment created time in 2 months

more