NSObject+RACLifting.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //
  2. // NSObject+RACLifting.h
  3. // ReactiveObjC
  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<__covariant ValueType>;
  10. NS_ASSUME_NONNULL_BEGIN
  11. @interface NSObject (RACLifting)
  12. /// Lifts the selector on the receiver into the reactive world. The selector will
  13. /// be invoked whenever any signal argument sends a value, but only after each
  14. /// signal has sent an initial value.
  15. ///
  16. /// It will replay the most recently sent value to new subscribers.
  17. ///
  18. /// This does not support C arrays or unions.
  19. ///
  20. /// selector - The selector on self to invoke.
  21. /// firstSignal - The signal corresponding to the first method argument. This
  22. /// must not be nil.
  23. /// ... - A list of RACSignals corresponding to the remaining arguments.
  24. /// There must be a non-nil signal for each method argument.
  25. ///
  26. /// Examples
  27. ///
  28. /// [button rac_liftSelector:@selector(setTitleColor:forState:) withSignals:textColorSignal, [RACSignal return:@(UIControlStateNormal)], nil];
  29. ///
  30. /// Returns a signal which sends the return value from each invocation of the
  31. /// selector. If the selector returns void, it instead sends RACUnit.defaultUnit.
  32. /// It completes only after all the signal arguments complete.
  33. - (RACSignal *)rac_liftSelector:(SEL)selector withSignals:(RACSignal *)firstSignal, ... NS_REQUIRES_NIL_TERMINATION;
  34. /// Like -rac_liftSelector:withSignals:, but accepts an array instead of
  35. /// a variadic list of arguments.
  36. - (RACSignal *)rac_liftSelector:(SEL)selector withSignalsFromArray:(NSArray *)signals;
  37. /// Like -rac_liftSelector:withSignals:, but accepts a signal sending tuples of
  38. /// arguments instead of a variadic list of arguments.
  39. - (RACSignal *)rac_liftSelector:(SEL)selector withSignalOfArguments:(RACSignal *)arguments;
  40. @end
  41. NS_ASSUME_NONNULL_END