RACEvent.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. //
  2. // RACEvent.h
  3. // ReactiveCocoa
  4. //
  5. // Created by Justin Spahr-Summers on 2013-01-07.
  6. // Copyright (c) 2013 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. /// Describes the type of a RACEvent.
  10. ///
  11. /// RACEventTypeCompleted - A `completed` event.
  12. /// RACEventTypeError - An `error` event.
  13. /// RACEventTypeNext - A `next` event.
  14. typedef NS_ENUM(NSUInteger, RACEventType) {
  15. RACEventTypeCompleted,
  16. RACEventTypeError,
  17. RACEventTypeNext
  18. };
  19. /// Represents an event sent by a RACSignal.
  20. ///
  21. /// This corresponds to the `Notification` class in Rx.
  22. @interface RACEvent : NSObject <NSCopying>
  23. /// Returns a singleton RACEvent representing the `completed` event.
  24. + (instancetype)completedEvent;
  25. /// Returns a new event of type RACEventTypeError, containing the given error.
  26. + (instancetype)eventWithError:(NSError *)error;
  27. /// Returns a new event of type RACEventTypeNext, containing the given value.
  28. + (instancetype)eventWithValue:(id)value;
  29. /// The type of event represented by the receiver.
  30. @property (nonatomic, assign, readonly) RACEventType eventType;
  31. /// Returns whether the receiver is of type RACEventTypeCompleted or
  32. /// RACEventTypeError.
  33. @property (nonatomic, getter = isFinished, assign, readonly) BOOL finished;
  34. /// The error associated with an event of type RACEventTypeError. This will be
  35. /// nil for all other event types.
  36. @property (nonatomic, strong, readonly) NSError *error;
  37. /// The value associated with an event of type RACEventTypeNext. This will be
  38. /// nil for all other event types.
  39. @property (nonatomic, strong, readonly) id value;
  40. @end