Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Address Reducer._printChanges() sendability #3320

Merged
merged 2 commits into from
Aug 30, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions Sources/ComposableArchitecture/Reducer/Reducers/DebugReducer.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import Combine
import Dispatch

extension Reducer {
extension Reducer where State: Sendable, Action: Sendable {
/// Enhances a reducer with debug logging of received actions and state mutations for the given
/// printer.
///
Expand All @@ -21,13 +21,21 @@ extension Reducer {

private let printQueue = DispatchQueue(label: "co.pointfree.swift-composable-architecture.printer")

public struct _ReducerPrinter<State, Action> {
private let _printChange: (_ receivedAction: Action, _ oldState: State, _ newState: State) -> Void
public struct _ReducerPrinter<State, Action>: Sendable {
private let _printChange: @Sendable (
_ receivedAction: Action,
_ oldState: State,
_ newState: State
) -> Void
@usableFromInline
let queue: DispatchQueue

public init(
printChange: @escaping (_ receivedAction: Action, _ oldState: State, _ newState: State) -> Void,
printChange: @escaping @Sendable (
_ receivedAction: Action,
_ oldState: State,
_ newState: State
) -> Void,
queue: DispatchQueue? = nil
) {
self._printChange = printChange
Expand Down Expand Up @@ -58,7 +66,8 @@ extension _ReducerPrinter {
}
}

public struct _PrintChangesReducer<Base: Reducer>: Reducer {
public struct _PrintChangesReducer<Base: Reducer>: Reducer
where Base.State: Sendable, Base.Action: Sendable {
@usableFromInline
let base: Base

Expand Down