Should a reducer conform to the Sendable protocol?

Hello,

I am currently in charge of preparing our project (iOS, tvOS) to embrace Swift concurrency. The first thing I did was to bump the library to the stable version. We previously used the 0. version of the library. I moved our reducers to use the async/await notation from the Combine-based reducers notation. However, when I rewrote our reducers to use the async/await notation, I had some warnings that could be solved by making a reducer conform to Sendable protocol.

Without any more context of the problem, do you think a Reducer should be sendable?

Hi @setoelkahfi, if you are going to access the reducer from within an effect, then yes it will need to be Sendable. This is typically very easy to do since reducers are usually value types and usually only hold onto sendable values (e.g. @Dependency).

Hey @mbrandonw, thanks for the reply.

We haven't migrated our reducers to using the @Dependency style. We do have some +Client structs style for our networking layer. So it means that those clients should have sendable closure as well to make them sendable, right?

Like so:

struct APIClient: Sendable {
     public var pageAt: @Sendable (Link, PageRequestInput)
        -> AnyPublisher<PageResponse, NetworkSession.SessionError<ErrorResponse>>

}