From 19e4b7cd52000c72862d21d7028e8882abee1602 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9C=D0=B8=D1=85=D0=B0=D0=B8=D0=BB=20=D0=9A=D0=B0=D0=BF?= =?UTF-8?q?=D0=B5=D0=BB=D1=8C=D0=BA=D0=BE?= Date: Tue, 26 Dec 2023 12:54:38 +0300 Subject: [PATCH] d --- src/Bus.Receiver.swift | 15 +++++++++++++++ src/Bus.Sender.swift | 15 +++++++++++++++ src/VM.swift | 2 +- 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/Bus.Receiver.swift create mode 100644 src/Bus.Sender.swift diff --git a/src/Bus.Receiver.swift b/src/Bus.Receiver.swift new file mode 100644 index 0000000..dab632d --- /dev/null +++ b/src/Bus.Receiver.swift @@ -0,0 +1,15 @@ +import Combine + +public extension Bus { + final class Receiver { + var subscriptions = [AnyCancellable]() + + public init( + _ keys: Set, + _ handler: @escaping ((String, T) -> Void), + opt: [Option] = [], + { + Bus.receive(keys, handler, opt: opt, sub: &subscriptions) + } + } +} diff --git a/src/Bus.Sender.swift b/src/Bus.Sender.swift new file mode 100644 index 0000000..146638c --- /dev/null +++ b/src/Bus.Sender.swift @@ -0,0 +1,15 @@ +import Combine + +public extension Bus { + final class Sender { + var subscriptions = [AnyCancellable]() + + public init( + _ key: String, + _ node: AnyPublisher, + opt: [Option] = [] + ) { + Bus.send(key, node, opt: opt, sub: &subscriptions) + } + } +} diff --git a/src/VM.swift b/src/VM.swift index f337d33..b8c34f2 100644 --- a/src/VM.swift +++ b/src/VM.swift @@ -7,7 +7,7 @@ final class VM: ObservableObject { var subscriptions = [AnyCancellable]() init() { - Bus.send( + Bus.send( MeetupId.K.meetupIdTextUI.rawValue, $text // Исключаем конфликты от UI и App путём игнорирования спама.