Skip to content

Commit 21f2dd5

Browse files
authored
Merge debug reducer to avoid Combine leak (#195)
1 parent 284e5fc commit 21f2dd5

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Sources/ComposableArchitecture/Debugging/ReducerDebugging.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ extension Reducer {
106106
guard let localAction = toLocalAction.extract(from: action) else { return effects }
107107
let nextState = toLocalState(state)
108108
let debugEnvironment = toDebugEnvironment(environment)
109-
return .concatenate(
109+
return .merge(
110110
.fireAndForget {
111111
debugEnvironment.queue.async {
112112
let actionOutput =

Sources/ComposableArchitecture/Effect.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ public struct Effect<Output, Failure: Error>: Publisher {
170170
/// Concatenates a variadic list of effects together into a single effect, which runs the effects
171171
/// one after the other.
172172
///
173+
/// - Warning: Combine's `Publishers.Concatenate` operator, which this function uses, can leak
174+
/// when its suffix is a `Publishers.MergeMany` operator, which is used throughout the
175+
/// Composable Architecture in functions like `Reducer.combine`.
176+
///
177+
/// Feedback filed: <https://gist.github.com/mbrandonw/611c8352e1bd1c22461bd505e320ab58>
178+
///
173179
/// - Parameter effects: A variadic list of effects.
174180
/// - Returns: A new effect
175181
public static func concatenate(_ effects: Effect...) -> Effect {
@@ -179,6 +185,12 @@ public struct Effect<Output, Failure: Error>: Publisher {
179185
/// Concatenates a collection of effects together into a single effect, which runs the effects one
180186
/// after the other.
181187
///
188+
/// - Warning: Combine's `Publishers.Concatenate` operator, which this function uses, can leak
189+
/// when its suffix is a `Publishers.MergeMany` operator, which is used throughout the
190+
/// Composable Architecture in functions like `Reducer.combine`.
191+
///
192+
/// Feedback filed: <https://gist.github.com/mbrandonw/611c8352e1bd1c22461bd505e320ab58>
193+
///
182194
/// - Parameter effects: A collection of effects.
183195
/// - Returns: A new effect
184196
public static func concatenate<C: Collection>(

0 commit comments

Comments
 (0)