RACMulticastConnection.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. //
  2. // RACMulticastConnection.h
  3. // ReactiveObjC
  4. //
  5. // Created by Josh Abernathy on 4/11/12.
  6. // Copyright (c) 2012 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. #import "RACAnnotations.h"
  10. @class RACDisposable;
  11. @class RACSignal<__covariant ValueType>;
  12. NS_ASSUME_NONNULL_BEGIN
  13. /// A multicast connection encapsulates the idea of sharing one subscription to a
  14. /// signal to many subscribers. This is most often needed if the subscription to
  15. /// the underlying signal involves side-effects or shouldn't be called more than
  16. /// once.
  17. ///
  18. /// The multicasted signal is only subscribed to when
  19. /// -[RACMulticastConnection connect] is called. Until that happens, no values
  20. /// will be sent on `signal`. See -[RACMulticastConnection autoconnect] for how
  21. /// -[RACMulticastConnection connect] can be called automatically.
  22. ///
  23. /// Note that you shouldn't create RACMulticastConnection manually. Instead use
  24. /// -[RACSignal publish] or -[RACSignal multicast:].
  25. @interface RACMulticastConnection<__covariant ValueType> : NSObject
  26. /// The multicasted signal.
  27. @property (nonatomic, strong, readonly) RACSignal<ValueType> *signal;
  28. /// Connect to the underlying signal by subscribing to it. Calling this multiple
  29. /// times does nothing but return the existing connection's disposable.
  30. ///
  31. /// Returns the disposable for the subscription to the multicasted signal.
  32. - (RACDisposable *)connect;
  33. /// Connects to the underlying signal when the returned signal is first
  34. /// subscribed to, and disposes of the subscription to the multicasted signal
  35. /// when the returned signal has no subscribers.
  36. ///
  37. /// If new subscribers show up after being disposed, they'll subscribe and then
  38. /// be immediately disposed of. The returned signal will never re-connect to the
  39. /// multicasted signal.
  40. ///
  41. /// Returns the autoconnecting signal.
  42. - (RACSignal<ValueType> *)autoconnect RAC_WARN_UNUSED_RESULT;
  43. @end
  44. NS_ASSUME_NONNULL_END