Is 'fireAndForget' still a thing in Composable Architecture

484 Views Asked by At

With the release of Composable Architecture 1.0, what is the recommended way to fire off arbitrary code from a Reducer?

In the old days this was handled with return Effect.fireAndForget{//code here}

I know TCA is moving away from Apple's Combine library, which was used to handle fireAndForget.

So what's the approved way now to return a block of arbitrary code that does not involve feeding further actions back into the reducer?

(Helpful if examples can be provided for async and non-async code.)

1

There are 1 best solutions below

0
On

After some digging, it appears 'fireAndForget' is fully deprecated. The replacement is:

return Effect.run { _ in 
//async code here
}

In the words of the library authors:

Effect.fireAndForget would be more simply handled by an Effect.run that ignores the send argument, and thus cannot feed actions back into the store: It's fewer characters that just as loudly signal intent.

Some more background here: https://github.com/pointfreeco/swift-composable-architecture/discussions/1477