RACEvent.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. //
  2. // RACEvent.h
  3. // ReactiveObjC
  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. NS_ASSUME_NONNULL_BEGIN
  10. /// Describes the type of a RACEvent.
  11. ///
  12. /// RACEventTypeCompleted - A `completed` event.
  13. /// RACEventTypeError - An `error` event.
  14. /// RACEventTypeNext - A `next` event.
  15. typedef NS_ENUM(NSUInteger, RACEventType) {
  16. RACEventTypeCompleted,
  17. RACEventTypeError,
  18. RACEventTypeNext
  19. };
  20. /// Represents an event sent by a RACSignal.
  21. ///
  22. /// This corresponds to the `Notification` class in Rx.
  23. @interface RACEvent<__covariant ValueType> : NSObject <NSCopying>
  24. /// Returns a singleton RACEvent representing the `completed` event.
  25. + (RACEvent<ValueType> *)completedEvent;
  26. /// Returns a new event of type RACEventTypeError, containing the given error.
  27. + (RACEvent<ValueType> *)eventWithError:(nullable NSError *)error;
  28. /// Returns a new event of type RACEventTypeNext, containing the given value.
  29. + (RACEvent<ValueType> *)eventWithValue:(nullable ValueType)value;
  30. /// The type of event represented by the receiver.
  31. @property (nonatomic, assign, readonly) RACEventType eventType;
  32. /// Returns whether the receiver is of type RACEventTypeCompleted or
  33. /// RACEventTypeError.
  34. @property (nonatomic, getter = isFinished, assign, readonly) BOOL finished;
  35. /// The error associated with an event of type RACEventTypeError. This will be
  36. /// nil for all other event types.
  37. @property (nonatomic, strong, readonly, nullable) NSError *error;
  38. /// The value associated with an event of type RACEventTypeNext. This will be
  39. /// nil for all other event types.
  40. @property (nonatomic, strong, readonly, nullable) ValueType value;
  41. @end
  42. NS_ASSUME_NONNULL_END