|
@@ -16,7 +16,7 @@ public extension Bus { |
|
|
_ handler: @escaping ((String, T) -> Void), |
|
|
_ handler: @escaping ((String, T) -> Void), |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
) { |
|
|
) { |
|
|
Self.events |
|
|
|
|
|
|
|
|
e |
|
|
.compactMap { convertKeyValue(keys, $0) } |
|
|
.compactMap { convertKeyValue(keys, $0) } |
|
|
.receive(on: DispatchQueue.main) |
|
|
.receive(on: DispatchQueue.main) |
|
|
.sink { v in handler(v.0, v.1) } |
|
|
.sink { v in handler(v.0, v.1) } |
|
@@ -29,7 +29,7 @@ public extension Bus { |
|
|
_ handler: @escaping ((String, T) -> Void), |
|
|
_ handler: @escaping ((String, T) -> Void), |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
) { |
|
|
) { |
|
|
Self.events |
|
|
|
|
|
|
|
|
e |
|
|
.compactMap { convertKeyValue(keys, $0) } |
|
|
.compactMap { convertKeyValue(keys, $0) } |
|
|
.sink { v in handler(v.0, v.1) } |
|
|
.sink { v in handler(v.0, v.1) } |
|
|
.store(in: &subscriptions) |
|
|
.store(in: &subscriptions) |
|
@@ -43,7 +43,7 @@ public extension Bus { |
|
|
) { |
|
|
) { |
|
|
node |
|
|
node |
|
|
.receive(on: DispatchQueue.main) |
|
|
.receive(on: DispatchQueue.main) |
|
|
.sink { v in Self.e.send((key, v)) } |
|
|
|
|
|
|
|
|
.sink { v in e.send((key, v)) } |
|
|
.store(in: &subscriptions) |
|
|
.store(in: &subscriptions) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -54,13 +54,13 @@ public extension Bus { |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
) { |
|
|
) { |
|
|
node |
|
|
node |
|
|
.sink { v in Self.e.send((key, v)) } |
|
|
|
|
|
|
|
|
.sink { v in e.send((key, v)) } |
|
|
.store(in: &subscriptions) |
|
|
.store(in: &subscriptions) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// Синхронно отправить событие в шину один раз. |
|
|
/// Синхронно отправить событие в шину один раз. |
|
|
static func send(_ key: String, _ value: Any) { |
|
|
static func send(_ key: String, _ value: Any) { |
|
|
Self.e.send((key, value)) |
|
|
|
|
|
|
|
|
e.send((key, value)) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -71,7 +71,7 @@ public extension Bus { |
|
|
_ handler: @escaping ((Src) -> Dst?), |
|
|
_ handler: @escaping ((Src) -> Dst?), |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
) { |
|
|
) { |
|
|
Self.events |
|
|
|
|
|
|
|
|
e |
|
|
.compactMap { processKeysValue($0, keysIn, handler) } |
|
|
.compactMap { processKeysValue($0, keysIn, handler) } |
|
|
.receive(on: DispatchQueue.main) |
|
|
.receive(on: DispatchQueue.main) |
|
|
.sink { vOut in Self.e.send((keyOut, vOut)) } |
|
|
.sink { vOut in Self.e.send((keyOut, vOut)) } |
|
@@ -84,7 +84,7 @@ public extension Bus { |
|
|
_ handler: @escaping ((Src) -> Dst?), |
|
|
_ handler: @escaping ((Src) -> Dst?), |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
_ subscriptions: inout [AnyCancellable] |
|
|
) { |
|
|
) { |
|
|
Self.events |
|
|
|
|
|
|
|
|
e |
|
|
.compactMap { processKeysValue($0, keysIn, handler) } |
|
|
.compactMap { processKeysValue($0, keysIn, handler) } |
|
|
.sink { vOut in Self.e.send((keyOut, vOut)) } |
|
|
.sink { vOut in Self.e.send((keyOut, vOut)) } |
|
|
.store(in: &subscriptions) |
|
|
.store(in: &subscriptions) |
|
|