diff --git a/Modules/BusX/Bus/src/Bus.swift b/Modules/BusX/Bus/src/Bus.swift index 33ae467..86bd66e 100644 --- a/Modules/BusX/Bus/src/Bus.swift +++ b/Modules/BusX/Bus/src/Bus.swift @@ -45,12 +45,13 @@ public extension Bus { _ subscriptions: inout [AnyCancellable] ) { node - .sink { v in e.send((key, v)) } + .sink { v in send(key, v) } .store(in: &subscriptions) } /// Единоразово синхронно отправляем событие в шину. static func send(_ key: String, _ value: Any) { + /**/print("ИГР Bus.send k/v: '\(key)'/'\(value)'") e.send((key, value)) } } diff --git a/Modules/BusX/BusUI/src/BusUI.Button.swift b/Modules/BusX/BusUI/src/BusUI.Button.swift index 44166aa..69c23b9 100644 --- a/Modules/BusX/BusUI/src/BusUI.Button.swift +++ b/Modules/BusX/BusUI/src/BusUI.Button.swift @@ -5,9 +5,17 @@ extension BusUI { public let v = PassthroughSubject() 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 ) diff --git a/Modules/BusX/BusUI/src/BusUI.TextField.swift b/Modules/BusX/BusUI/src/BusUI.TextField.swift index c48ffd7..dbeba8b 100644 --- a/Modules/BusX/BusUI/src/BusUI.TextField.swift +++ b/Modules/BusX/BusUI/src/BusUI.TextField.swift @@ -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 ) diff --git a/Modules/MeetupIdX/src/MeetupId.Component.swift b/Modules/MeetupIdX/src/MeetupId.Component.swift index 66dcd96..958dc34 100644 --- a/Modules/MeetupIdX/src/MeetupId.Component.swift +++ b/Modules/MeetupIdX/src/MeetupId.Component.swift @@ -1,3 +1,5 @@ +import BusX + extension MeetupId { final class Component: ObservableObject { var isJoinAvailable: BusUI.Value @@ -13,8 +15,8 @@ extension MeetupId { /**/print("ИГР MeetupIC.init") isJoinAvailable = .init(K.isJoinAvailable, false, id) isLoading = .init(K.isLoading, false, id) - join = .init(K.join) - textField = .init(K.textApp, K.textUI) + join = .init(K.join, id) + textField = .init(K.textApp, K.textUI, id) } } } diff --git a/src/App.swift b/src/App.swift index ddf2865..119c4a8 100644 --- a/src/App.swift +++ b/src/App.swift @@ -4,9 +4,9 @@ import UIKit struct Content: View { var body: some View { - MeetupId.V() + MeetupId.V("") Divider() - MeetupId.V() + MeetupId.V("abc") } }