Михаил Капелько 10 months ago
parent
commit
f3807b76f6
5 changed files with 29 additions and 10 deletions
  1. +2
    -1
      Modules/BusX/Bus/src/Bus.swift
  2. +10
    -2
      Modules/BusX/BusUI/src/BusUI.Button.swift
  3. +11
    -3
      Modules/BusX/BusUI/src/BusUI.TextField.swift
  4. +4
    -2
      Modules/MeetupIdX/src/MeetupId.Component.swift
  5. +2
    -2
      src/App.swift

+ 2
- 1
Modules/BusX/Bus/src/Bus.swift View File

@@ -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))
}
}

+ 10
- 2
Modules/BusX/BusUI/src/BusUI.Button.swift 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
)


+ 11
- 3
Modules/BusX/BusUI/src/BusUI.TextField.swift 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
)


+ 4
- 2
Modules/MeetupIdX/src/MeetupId.Component.swift View File

@@ -1,3 +1,5 @@
import BusX

extension MeetupId {
final class Component: ObservableObject {
var isJoinAvailable: BusUI.Value<Bool>
@@ -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)
}
}
}


+ 2
- 2
src/App.swift View File

@@ -4,9 +4,9 @@ import UIKit

struct Content: View {
var body: some View {
MeetupId.V()
MeetupId.V("")
Divider()
MeetupId.V()
MeetupId.V("abc")
}
}



Loading…
Cancel
Save