@@ -291,6 +291,7 @@ public final class Store<State, Action> {
291
291
state toLocalState: @escaping ( State ) -> LocalState ,
292
292
action fromLocalAction: @escaping ( LocalAction ) -> Action
293
293
) -> Store < LocalState , LocalAction > {
294
+ self . threadCheck ( status: . scope)
294
295
var isSending = false
295
296
let localStore = Store < LocalState , LocalAction > (
296
297
initialState: toLocalState ( self . state) ,
@@ -436,6 +437,7 @@ public final class Store<State, Action> {
436
437
437
438
private enum ThreadCheckStatus {
438
439
case effectCompletion( Action )
440
+ case scope
439
441
case send( Action , isFromViewStore: Bool )
440
442
}
441
443
@@ -449,22 +451,28 @@ public final class Store<State, Action> {
449
451
switch status {
450
452
case let . effectCompletion( action) :
451
453
message = """
452
- An effect returned from the action " \( debugCaseOutput ( action) ) " completed on the \
453
- wrong thread. Make sure to use " .receive(on:) " on any effects that execute on background \
454
+ An effect returned from the action " \( debugCaseOutput ( action) ) " completed on the wrong \
455
+ thread. Make sure to use " .receive(on:) " on any effects that execute on background \
454
456
threads to receive their output on the same thread the store was created on.
455
457
"""
456
458
459
+ case . scope:
460
+ message = """
461
+ " Store.scope " was called on the wrong thread. Make sure that " Store.scope " is always \
462
+ called on the same thread the store was created on.
463
+ """
464
+
457
465
case let . send( action, isFromViewStore: true ) :
458
466
message = """
459
- " ViewStore.send( \( debugCaseOutput ( action) ) ) " was called on the wrong thread. Make \
460
- sure that " ViewStore.send " is always called on the same thread the store was created on.
467
+ " ViewStore.send( \( debugCaseOutput ( action) ) ) " was called on the wrong thread. Make sure \
468
+ that " ViewStore.send " is always called on the same thread the store was created on.
461
469
"""
462
470
463
471
case let . send( action, isFromViewStore: false ) :
464
472
message = """
465
- An effect emitted the action " \( debugCaseOutput ( action) ) " from the wrong thread. Make sure \
466
- to use " .receive(on:) " on any effects that execute on background threads to receive their \
467
- output on the same thread the store was created on.
473
+ An effect emitted the action " \( debugCaseOutput ( action) ) " from the wrong thread. Make \
474
+ sure to use " .receive(on:) " on any effects that execute on background threads to receive \
475
+ their output on the same thread the store was created on.
468
476
"""
469
477
}
470
478
0 commit comments