RACSubscriber.h 1.7 KB

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