Михаил Капелько 10 个月前
父节点
当前提交
576f67e882
共有 1 个文件被更改,包括 7 次插入7 次删除
  1. +7
    -7
      Modules/BusX/Bus/src/Bus.swift

+ 7
- 7
Modules/BusX/Bus/src/Bus.swift 查看文件

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


正在加载...
取消
保存