|
|
@@ -3,6 +3,7 @@ import Foundation |
|
|
|
|
|
|
|
public enum Bus { |
|
|
|
static let e = PassthroughSubject<(key: String, value: Any), Never>() |
|
|
|
/**/static var subscriptions = [AnyCancellable]() |
|
|
|
} |
|
|
|
|
|
|
|
public extension Bus { |
|
|
@@ -70,20 +71,20 @@ public extension Bus { |
|
|
|
if isAsync { |
|
|
|
subscription = node |
|
|
|
.receive(on: DispatchQueue.main) |
|
|
|
.sink { v in Self.e.send(key, v) } |
|
|
|
.sink { v in Self.e.send((key, v)) } |
|
|
|
} |
|
|
|
|
|
|
|
// Sync. |
|
|
|
if !isAsync { |
|
|
|
subscription = node |
|
|
|
.sink { v in Self.e.send(key, v) } |
|
|
|
.sink { v in Self.e.send((key, v)) } |
|
|
|
} |
|
|
|
|
|
|
|
subscribe(subscription, sub) |
|
|
|
} |
|
|
|
|
|
|
|
static func send(_ key: String, _ value: Any) { |
|
|
|
Self.e.send(key, value) |
|
|
|
Self.e.send((key, value)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -103,14 +104,14 @@ public extension Bus { |
|
|
|
subscription = Self.events |
|
|
|
.compactMap { processKeysValue($0, keysIn, handler) } |
|
|
|
.receive(on: DispatchQueue.main) |
|
|
|
.sink { vOut in Self.e.send(keyOut, vOut) } |
|
|
|
.sink { vOut in Self.e.send((keyOut, vOut)) } |
|
|
|
} |
|
|
|
|
|
|
|
// Sync. |
|
|
|
if !isAsync { |
|
|
|
subscription = Self.events |
|
|
|
.compactMap { processKeysValue($0, keysIn, handler) } |
|
|
|
.sink { vOut in Self.e.send(keyOut, vOut) } |
|
|
|
.sink { vOut in Self.e.send((keyOut, vOut)) } |
|
|
|
} |
|
|
|
|
|
|
|
subscribe(subscription, sub) |
|
|
|