RACMulticastConnection.h 1.7 KB

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