This commit is contained in:
Михаил Капелько
2023-12-26 12:54:38 +03:00
parent ab91e074d9
commit 19e4b7cd52
3 changed files with 31 additions and 1 deletions

15
src/Bus.Receiver.swift Normal file
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
src/Bus.Sender.swift Normal file
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)
}
}
}

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 путём игнорирования спама.