Проверка шаблона шины для iOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
601B

  1. import Combine
  2. public extension Bus {
  3. final class Receiver<T> {
  4. var subscriptions = [AnyCancellable]()
  5. public init(
  6. _ keys: Set<String>,
  7. _ handler: @escaping ((String, T) -> Void),
  8. opt: [Option] = []
  9. ) {
  10. Bus.receive(keys, handler, opt: opt, sub: &subscriptions)
  11. }
  12. }
  13. }
  14. import Combine
  15. public extension Bus {
  16. final class Sender<T> {
  17. var subscriptions = [AnyCancellable]()
  18. public init(
  19. _ key: String,
  20. _ node: AnyPublisher<T, Never>,
  21. opt: [Option] = []
  22. ) {
  23. Bus.send(key, node, opt: opt, sub: &subscriptions)
  24. }
  25. }
  26. }