Проверка шаблона шины для iOS
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

58 lignes
1.3KB

  1. import Combine
  2. import MPAKX
  3. import SwiftUI
  4. extension BusUI {
  5. public final class ManyTextField: ObservableObject {
  6. let textApp: String
  7. let textUI: String
  8. @Published public var id: String?
  9. @Published public var v = "a:"
  10. var subscriptions = [AnyCancellable]()
  11. var sub = [AnyCancellable]()
  12. public init(
  13. _ textApp: String,
  14. _ textUI: String
  15. ) {
  16. self.textApp = textApp
  17. self.textUI = textUI
  18. /**///print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).init textA/textU: '\(textApp)'/'\(textUI)'")
  19. $id
  20. .sink { [weak self] v in self?.setup(v) }
  21. .store(in: &sub)
  22. }
  23. private func setup(_ id: String?) {
  24. /**/print("ИГР BusUTF(\(Unmanaged.passUnretained(self).toOpaque())).setup id: '\(id)'")
  25. subscriptions = []
  26. Bus.sendSync(
  27. textUI,
  28. $v
  29. .removeDuplicates()
  30. .compactMap(onlyUIText)
  31. .compactMap { v in
  32. if let id {
  33. var d = [String: String]()
  34. d[id] = v
  35. return MPAK.Many([id], d)
  36. }
  37. return v
  38. }
  39. .eraseToAnyPublisher(),
  40. &subscriptions
  41. )
  42. Bus.receiveSync(
  43. [textApp],
  44. { [weak self] (_, v: String) in self?.v = "a:\(v)" },
  45. &subscriptions
  46. )
  47. }
  48. }
  49. }