NSObject+RACLifting.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. //
  2. // NSObject+RACLifting.h
  3. // ReactiveCocoa
  4. //
  5. // Created by Josh Abernathy on 10/13/12.
  6. // Copyright (c) 2012 GitHub, Inc. All rights reserved.
  7. //
  8. #import <Foundation/Foundation.h>
  9. @class RACSignal;
  10. @interface NSObject (RACLifting)
  11. /// Lifts the selector on the receiver into the reactive world. The selector will
  12. /// be invoked whenever any signal argument sends a value, but only after each
  13. /// signal has sent an initial value.
  14. ///
  15. /// It will replay the most recently sent value to new subscribers.
  16. ///
  17. /// This does not support C arrays or unions.
  18. ///
  19. /// selector - The selector on self to invoke.
  20. /// firstSignal - The signal corresponding to the first method argument. This
  21. /// must not be nil.
  22. /// ... - A list of RACSignals corresponding to the remaining arguments.
  23. /// There must be a non-nil signal for each method argument.
  24. ///
  25. /// Examples
  26. ///
  27. /// [button rac_liftSelector:@selector(setTitleColor:forState:) withSignals:textColorSignal, [RACSignal return:@(UIControlStateNormal)], nil];
  28. ///
  29. /// Returns a signal which sends the return value from each invocation of the
  30. /// selector. If the selector returns void, it instead sends RACUnit.defaultUnit.
  31. /// It completes only after all the signal arguments complete.
  32. - (RACSignal *)rac_liftSelector:(SEL)selector withSignals:(RACSignal *)firstSignal, ... NS_REQUIRES_NIL_TERMINATION;
  33. /// Like -rac_liftSelector:withSignals:, but accepts an array instead of
  34. /// a variadic list of arguments.
  35. - (RACSignal *)rac_liftSelector:(SEL)selector withSignalsFromArray:(NSArray *)signals;
  36. /// Like -rac_liftSelector:withSignals:, but accepts a signal sending tuples of
  37. /// arguments instead of a variadic list of arguments.
  38. - (RACSignal *)rac_liftSelector:(SEL)selector withSignalOfArguments:(RACSignal *)arguments;
  39. @end
  40. @interface NSObject (RACUnavailableLifting)
  41. - (RACSignal *)rac_liftSelector:(SEL)selector withObjects:(id)arg, ... __attribute__((unavailable("Use -rac_liftSelector:withSignals: instead")));
  42. - (RACSignal *)rac_liftSelector:(SEL)selector withObjectsFromArray:(NSArray *)args __attribute__((unavailable("Use -rac_liftSelector:withSignalsFromArray: instead")));
  43. - (RACSignal *)rac_liftBlock:(id)block withArguments:(id)arg, ... NS_REQUIRES_NIL_TERMINATION __attribute__((unavailable("Use +combineLatest:reduce: instead")));
  44. - (RACSignal *)rac_liftBlock:(id)block withArgumentsFromArray:(NSArray *)args __attribute__((unavailable("Use +combineLatest:reduce: instead")));
  45. - (instancetype)rac_lift __attribute__((unavailable("Use -rac_liftSelector:withSignals: instead")));
  46. @end