Skip to content

Commit 83d0907

Browse files
stephencelismluisbrown
authored andcommitted
Don't spin up long-living test effects for .none
(cherry picked from commit f94988ec8e1770fcb3dff8cacd643d945d20cd53) # Conflicts: # Sources/ComposableArchitecture/TestStore.swift
1 parent 75183d2 commit 83d0907

File tree

1 file changed

+21
-17
lines changed

1 file changed

+21
-17
lines changed

Sources/ComposableArchitecture/TestStore.swift

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -267,23 +267,27 @@
267267
self.receivedActions.append((action, state))
268268
}
269269

270-
let effect = LongLivingEffect(file: action.file, line: action.line)
271-
return
272-
effects
273-
.producer
274-
.on(
275-
starting: { [effectDidSubscribe = self.effectDidSubscribe, weak self] in
276-
self?.inFlightEffects.insert(effect)
277-
Task {
278-
await Task.megaYield()
279-
effectDidSubscribe.continuation.yield()
280-
}
281-
},
282-
completed: { [weak self] in self?.inFlightEffects.remove(effect) },
283-
disposed: { [weak self] in self?.inFlightEffects.remove(effect) }
284-
)
285-
.eraseToEffect { .init(origin: .receive($0), file: action.file, line: action.line) }
286-
270+
switch effects.operation {
271+
case .none:
272+
return .none
273+
case .producer, .run:
274+
let effect = LongLivingEffect(file: action.file, line: action.line)
275+
return
276+
effects
277+
.producer
278+
.on(
279+
starting: { [effectDidSubscribe = self.effectDidSubscribe, weak self] in
280+
self?.inFlightEffects.insert(effect)
281+
Task {
282+
await Task.megaYield()
283+
effectDidSubscribe.continuation.yield()
284+
}
285+
},
286+
completed: { [weak self] in self?.inFlightEffects.remove(effect) },
287+
disposed: { [weak self] in self?.inFlightEffects.remove(effect) }
288+
)
289+
.eraseToEffect { .init(origin: .receive($0), file: action.file, line: action.line) }
290+
}
287291
},
288292
environment: ()
289293
)

0 commit comments

Comments
 (0)