RACSubscriber.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // RACSubscriber.h
  3. // ReactiveCocoa
  4. //
  5. // Created by Josh Abernathy on 3/1/12.
  6. // Copyright (c) 2012 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class RACCompoundDisposable;
  10. /// Represents any object which can directly receive values from a RACSignal.
  11. ///
  12. /// You generally shouldn't need to implement this protocol. +[RACSignal
  13. /// createSignal:], RACSignal's subscription methods, or RACSubject should work
  14. /// for most uses.
  15. ///
  16. /// Implementors of this protocol may receive messages and values from multiple
  17. /// threads simultaneously, and so should be thread-safe. Subscribers will also
  18. /// be weakly referenced so implementations must allow that.
  19. @protocol RACSubscriber <NSObject>
  20. @required
  21. /// Sends the next value to subscribers.
  22. ///
  23. /// value - The value to send. This can be `nil`.
  24. - (void)sendNext:(id)value;
  25. /// Sends the error to subscribers.
  26. ///
  27. /// error - The error to send. This can be `nil`.
  28. ///
  29. /// This terminates the subscription, and invalidates the subscriber (such that
  30. /// it cannot subscribe to anything else in the future).
  31. - (void)sendError:(NSError *)error;
  32. /// Sends completed to subscribers.
  33. ///
  34. /// This terminates the subscription, and invalidates the subscriber (such that
  35. /// it cannot subscribe to anything else in the future).
  36. - (void)sendCompleted;
  37. /// Sends the subscriber a disposable that represents one of its subscriptions.
  38. ///
  39. /// A subscriber may receive multiple disposables if it gets subscribed to
  40. /// multiple signals; however, any error or completed events must terminate _all_
  41. /// subscriptions.
  42. - (void)didSubscribeWithDisposable:(RACCompoundDisposable *)disposable;
  43. @end