Skip to content

Commit f94988e

Browse files
committed
Don't spin up long-living test effects for .none
1 parent d4834b5 commit f94988e

File tree

1 file changed

+21
-16
lines changed

1 file changed

+21
-16
lines changed

Sources/ComposableArchitecture/TestStore.swift

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -263,22 +263,27 @@
263263
self.receivedActions.append((action, state))
264264
}
265265

266-
let effect = LongLivingEffect(file: action.file, line: action.line)
267-
return
268-
effects
269-
.handleEvents(
270-
receiveSubscription: { [effectDidSubscribe = self.effectDidSubscribe, weak self] _ in
271-
self?.inFlightEffects.insert(effect)
272-
Task {
273-
await Task.megaYield()
274-
effectDidSubscribe.continuation.yield()
275-
}
276-
},
277-
receiveCompletion: { [weak self] _ in self?.inFlightEffects.remove(effect) },
278-
receiveCancel: { [weak self] in self?.inFlightEffects.remove(effect) }
279-
)
280-
.eraseToEffect { .init(origin: .receive($0), file: action.file, line: action.line) }
281-
266+
switch effects.operation {
267+
case .none:
268+
return .none
269+
case .publisher, .run:
270+
let effect = LongLivingEffect(file: action.file, line: action.line)
271+
return
272+
effects
273+
.handleEvents(
274+
receiveSubscription: {
275+
[effectDidSubscribe = self.effectDidSubscribe, weak self] _ in
276+
self?.inFlightEffects.insert(effect)
277+
Task {
278+
await Task.megaYield()
279+
effectDidSubscribe.continuation.yield()
280+
}
281+
},
282+
receiveCompletion: { [weak self] _ in self?.inFlightEffects.remove(effect) },
283+
receiveCancel: { [weak self] in self?.inFlightEffects.remove(effect) }
284+
)
285+
.eraseToEffect { .init(origin: .receive($0), file: action.file, line: action.line) }
286+
}
282287
},
283288
environment: ()
284289
)

0 commit comments

Comments
 (0)