d
This commit is contained in:
49
Modules/BusX/BusUI/src/BusUI.ManyTextField.swift
Normal file
49
Modules/BusX/BusUI/src/BusUI.ManyTextField.swift
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
import Combine
|
||||||
|
import SwiftUI
|
||||||
|
|
||||||
|
extension BusUI {
|
||||||
|
public final class ManyTextField: ObservableObject {
|
||||||
|
let textApp: String
|
||||||
|
let textUI: String
|
||||||
|
@Published public var id: String?
|
||||||
|
@Published public var v = "a:"
|
||||||
|
var subscriptions = [AnyCancellable]()
|
||||||
|
var sub = [AnyCancellable]()
|
||||||
|
|
||||||
|
public init(
|
||||||
|
_ textApp: String,
|
||||||
|
_ textUI: String
|
||||||
|
) {
|
||||||
|
self.textApp = textApp
|
||||||
|
self.textUI = textUI
|
||||||
|
|
||||||
|
/**///print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).init textA/textU: '\(textApp)'/'\(textUI)'")
|
||||||
|
|
||||||
|
$id
|
||||||
|
.sink { [weak self] v in self?.setup(v) }
|
||||||
|
.store(in: &sub)
|
||||||
|
}
|
||||||
|
|
||||||
|
private func setup(_ id: String?) {
|
||||||
|
/**/print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).setup id: '\(id)'")
|
||||||
|
|
||||||
|
subscriptions = []
|
||||||
|
|
||||||
|
Bus.sendSync(
|
||||||
|
textUI,
|
||||||
|
$v
|
||||||
|
.removeDuplicates()
|
||||||
|
.compactMap(onlyUIText)
|
||||||
|
.compactMap { .... + id? }
|
||||||
|
.eraseToAnyPublisher(),
|
||||||
|
&subscriptions
|
||||||
|
)
|
||||||
|
|
||||||
|
Bus.receiveSync(
|
||||||
|
[textApp],
|
||||||
|
{ [weak self] (_, v: String) in self?.v = "a:\(v)" },
|
||||||
|
&subscriptions
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,32 +3,13 @@ import SwiftUI
|
|||||||
|
|
||||||
extension BusUI {
|
extension BusUI {
|
||||||
public final class TextField: ObservableObject {
|
public final class TextField: ObservableObject {
|
||||||
let textApp: String
|
|
||||||
let textUI: String
|
|
||||||
@Published public var id: String?
|
|
||||||
@Published public var v = "a:"
|
@Published public var v = "a:"
|
||||||
var subscriptions = [AnyCancellable]()
|
var subscriptions = [AnyCancellable]()
|
||||||
var sub = [AnyCancellable]()
|
|
||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ textApp: String,
|
_ textApp: String,
|
||||||
_ textUI: String
|
_ textUI: String
|
||||||
) {
|
) {
|
||||||
self.textApp = textApp
|
|
||||||
self.textUI = textUI
|
|
||||||
|
|
||||||
/**///print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).init textA/textU: '\(textApp)'/'\(textUI)'")
|
|
||||||
|
|
||||||
$id
|
|
||||||
.sink { [weak self] v in self?.setup(v) }
|
|
||||||
.store(in: &sub)
|
|
||||||
}
|
|
||||||
|
|
||||||
private func setup(_ id: String?) {
|
|
||||||
/**/print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).setup id: '\(id)'")
|
|
||||||
|
|
||||||
subscriptions = []
|
|
||||||
|
|
||||||
Bus.sendSync(
|
Bus.sendSync(
|
||||||
textUI,
|
textUI,
|
||||||
$v
|
$v
|
||||||
|
|||||||
Reference in New Issue
Block a user