This commit is contained in:
Михаил Капелько
2024-01-06 18:31:59 +03:00
parent 56512ca26a
commit f3807b76f6
5 changed files with 29 additions and 10 deletions

View File

@@ -5,9 +5,17 @@ extension BusUI {
public let v = PassthroughSubject<Void, Never>()
var subscriptions = [AnyCancellable]()
public init(_ key: String) {
public init(
_ key: String,
_ id: String? = nil
) {
var k = key
if let id {
k = k + id
}
Bus.sendSync(
key,
k,
v.map { true }.eraseToAnyPublisher(),
&subscriptions
)

View File

@@ -8,10 +8,18 @@ extension BusUI {
public init(
_ textApp: String,
_ textUI: String
_ textUI: String,
_ id: String? = nil
) {
var ka = textApp
var ku = textUI
if let id {
ka = ka + id
ku = ku + id
}
Bus.sendSync(
textUI,
ku,
$v
.removeDuplicates()
.compactMap(onlyUIText)
@@ -20,7 +28,7 @@ extension BusUI {
)
Bus.receiveSync(
[textApp],
[ka],
{ [weak self] (_, v: String) in self?.v = "a:\(v)" },
&subscriptions
)