Михаил Капелько 1 year ago
parent
commit
19e4b7cd52
3 changed files with 31 additions and 1 deletions
  1. +15
    -0
      src/Bus.Receiver.swift
  2. +15
    -0
      src/Bus.Sender.swift
  3. +1
    -1
      src/VM.swift

+ 15
- 0
src/Bus.Receiver.swift View File

@@ -0,0 +1,15 @@
import Combine

public extension Bus {
final class Receiver<T> {
var subscriptions = [AnyCancellable]()

public init(
_ keys: Set<String>,
_ handler: @escaping ((String, T) -> Void),
opt: [Option] = [],
{
Bus.receive(keys, handler, opt: opt, sub: &subscriptions)
}
}
}

+ 15
- 0
src/Bus.Sender.swift View File

@@ -0,0 +1,15 @@
import Combine

public extension Bus {
final class Sender<T> {
var subscriptions = [AnyCancellable]()

public init(
_ key: String,
_ node: AnyPublisher<T, Never>,
opt: [Option] = []
) {
Bus.send(key, node, opt: opt, sub: &subscriptions)
}
}
}

+ 1
- 1
src/VM.swift View File

@@ -7,7 +7,7 @@ final class VM: ObservableObject {
var subscriptions = [AnyCancellable]()

init() {
Bus.send(
Bus.send(
MeetupId.K.meetupIdTextUI.rawValue,
$text
// Исключаем конфликты от UI и App путём игнорирования спама.


Loading…
Cancel
Save