RACMulticastConnection.h 1.8 KB

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