From 3d8813e1b9f34159a69442b20910db4ab14e64d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20Sandstr=C3=B6m?= Date: Wed, 22 Apr 2020 16:58:59 +0200 Subject: [PATCH] Add label and warning about raw loops --- MobiusCore/Source/EffectHandlers/EffectRouter.swift | 7 ++++++- MobiusCore/Test/EffectHandlers/EffectRouterTests.swift | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/MobiusCore/Source/EffectHandlers/EffectRouter.swift b/MobiusCore/Source/EffectHandlers/EffectRouter.swift index 7bbf5ec6..540b7ea9 100644 --- a/MobiusCore/Source/EffectHandlers/EffectRouter.swift +++ b/MobiusCore/Source/EffectHandlers/EffectRouter.swift @@ -107,8 +107,13 @@ public struct _PartialEffectRouter { /// Handle an the current `Effect` asynchronously on the provided `DispatchQueue` /// + /// Warning: Dispatching events to a loop from a different queue is not a thread-safe operation and will require + /// manual synchronization unless the loop is run in a `MobiusController`. + /// See: [Using MobiusController](https://github.com/spotify/Mobius.swift/wiki/Using-MobiusController). + /// + /// /// - Parameter queue: The `DispatchQueue` that the current `Effect` should be handled on. - public func on(_ queue: DispatchQueue) -> Self { + public func on(queue: DispatchQueue) -> Self { return Self(routes: routes, path: path, queue: queue) } } diff --git a/MobiusCore/Test/EffectHandlers/EffectRouterTests.swift b/MobiusCore/Test/EffectHandlers/EffectRouterTests.swift index a14d9ad0..4cbf15b0 100644 --- a/MobiusCore/Test/EffectHandlers/EffectRouterTests.swift +++ b/MobiusCore/Test/EffectHandlers/EffectRouterTests.swift @@ -212,7 +212,7 @@ class EffectRouterTests: QuickSpec { var ranOnTestQueue = false let connection = EffectRouter() .routeCase(.effect1) - .on(testQueue) + .on(queue: testQueue) .to { dispatchPrecondition(condition: .onQueue(testQueue)) ranOnTestQueue = true