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