|
|
@@ -85,9 +85,9 @@ public extension Bus { |
|
|
|
public extension Bus { |
|
|
|
static func processSync<Src, Dst>( |
|
|
|
_ subscriptions: inout Set<AnyCancellable>, |
|
|
|
_ handler: @escaping ((Src) -> Dst?), |
|
|
|
_ keyIn: String, |
|
|
|
_ keyOut: String, |
|
|
|
_ handler: @escaping ((Src) -> Dst?) |
|
|
|
_ keyOut: String |
|
|
|
) { |
|
|
|
Service.singleton.broadcaster |
|
|
|
.compactMap { |
|
|
@@ -102,4 +102,23 @@ public extension Bus { |
|
|
|
.sink { vOut in Service.singleton.send(keyOut, vOut) } |
|
|
|
.store(in: &subscriptions) |
|
|
|
} |
|
|
|
|
|
|
|
static func processSyncG<Src, Dst>( |
|
|
|
_ handler: @escaping ((Src) -> Dst?), |
|
|
|
_ keyIn: String, |
|
|
|
_ keyOut: String |
|
|
|
) { |
|
|
|
Service.singleton.broadcaster |
|
|
|
.compactMap { |
|
|
|
guard |
|
|
|
$0.key == keyIn, |
|
|
|
let vIn = $0.value as? Src |
|
|
|
else { |
|
|
|
return nil |
|
|
|
} |
|
|
|
return handler(vIn) |
|
|
|
} |
|
|
|
.sink { vOut in Service.singleton.send(keyOut, vOut) } |
|
|
|
.store(in: &Service.singleton.subscriptions) |
|
|
|
} |
|
|
|
} |