From c73ac28e09e8f4b4bdddf9d6185dede31daadb82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Sch=C3=BCtz?= Date: Tue, 30 Jun 2020 10:13:13 +0200 Subject: [PATCH] Fix RxSwift synchronization warning on bootstrap (#295) --- CoEpi/common/log/CachingLog.swift | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CoEpi/common/log/CachingLog.swift b/CoEpi/common/log/CachingLog.swift index 88bc66e..85ae341 100644 --- a/CoEpi/common/log/CachingLog.swift +++ b/CoEpi/common/log/CachingLog.swift @@ -28,6 +28,8 @@ class CachingLog: LogNonVariadicTags { private let addLogTrigger: PublishSubject = PublishSubject() private let disposeBag = DisposeBag() + private let loggerSerialQueue = DispatchQueue(label: "org.coepi.logger") + init() { addLogTrigger.withLatestFrom(logs, resultSelector: {(message, logs) in (message, logs) @@ -62,7 +64,9 @@ class CachingLog: LogNonVariadicTags { } private func log(_ message: LogMessage) { - addLogTrigger.onNext(message) + loggerSerialQueue.async { [weak self] in + self?.addLogTrigger.onNext(message) + } } private func addTag(tags: [LogTag], message: String) -> String {