Skip to content

Commit

Permalink
Merge debug reducer to avoid Combine leak (pointfreeco#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephencelis committed Jun 22, 2020
1 parent 284e5fc commit 21f2dd5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
Expand Up @@ -106,7 +106,7 @@ extension Reducer {
guard let localAction = toLocalAction.extract(from: action) else { return effects }
let nextState = toLocalState(state)
let debugEnvironment = toDebugEnvironment(environment)
return .concatenate(
return .merge(
.fireAndForget {
debugEnvironment.queue.async {
let actionOutput =
Expand Down
12 changes: 12 additions & 0 deletions Sources/ComposableArchitecture/Effect.swift
Expand Up @@ -170,6 +170,12 @@ public struct Effect<Output, Failure: Error>: Publisher {
/// Concatenates a variadic list of effects together into a single effect, which runs the effects
/// one after the other.
///
/// - Warning: Combine's `Publishers.Concatenate` operator, which this function uses, can leak
/// when its suffix is a `Publishers.MergeMany` operator, which is used throughout the
/// Composable Architecture in functions like `Reducer.combine`.
///
/// Feedback filed: <https://gist.github.com/mbrandonw/611c8352e1bd1c22461bd505e320ab58>
///
/// - Parameter effects: A variadic list of effects.
/// - Returns: A new effect
public static func concatenate(_ effects: Effect...) -> Effect {
Expand All @@ -179,6 +185,12 @@ public struct Effect<Output, Failure: Error>: Publisher {
/// Concatenates a collection of effects together into a single effect, which runs the effects one
/// after the other.
///
/// - Warning: Combine's `Publishers.Concatenate` operator, which this function uses, can leak
/// when its suffix is a `Publishers.MergeMany` operator, which is used throughout the
/// Composable Architecture in functions like `Reducer.combine`.
///
/// Feedback filed: <https://gist.github.com/mbrandonw/611c8352e1bd1c22461bd505e320ab58>
///
/// - Parameter effects: A collection of effects.
/// - Returns: A new effect
public static func concatenate<C: Collection>(
Expand Down

0 comments on commit 21f2dd5

Please sign in to comment.