First, common classes

  1. RACSiganl signal class.
-racemptysignal: empty signal used to implement the RACSignal +empty method; -racreturnSignal: unary signal, used to implement the RACSignal +return: method; -racDynamicSignal: a dynamic signal that uses a block - to implement the subscription, which is an instance of the RACSignal +createSignal: method. -racErrorSignal: error signal, used to implement the RACSignal +error: method; - RACChannelTerminal: represents a RACChannel terminal and is used to implement bidirectional binding.Copy the code
  1. RACSubscriber subscriber
  2. RACDisposable

It is used to unsubscribe or clean up resources and is triggered automatically when signaling is complete or in error.

RACSerialDisposable: Used as a disposable container, can contain a Disposable and allow the Disposable to be swapped out by atomic operations; - RACKVOTrampoline: represents a KVO observation and can be used to stop the observation; RACCompoundDisposable: It can contain multiple Disposable objects and supports manually adding and removing Disposable objects. It calls its own -Dispose method when it is dealloc.Copy the code
  1. The RACSubject signal provider can act as a signal and send a signal itself.
- RACGroupedSignal: a grouping signal to implement the RACSignal grouping function. -RacBehaviorSubject: a signal replays the last value. When subscribed, it sends the last value it received to the subscriber. - RACReplaySubject: replays the signal, saves the sent values, and resends them to the subscriber when subscribed.Copy the code
  1. The RACTuple tuple class, similar to NSArray, wraps values.
  2. RACSequence Collection classes in RAC
  3. RACCommand a class that handles events in an RAC environment. It can be used to monitor how events are handled and how data is transferred.
  4. RACMulticastConnection is used when a signal is subscribed to more than once. This class can be used to ensure that the signal is created without the side effects of multiple calls to the block used to create the signal.
  5. RACScheduler RAC queue, encapsulated in GCD.
-Racimmediatescheduler: The only scheduler that supports synchronous execution; - RACQueueScheduler: an abstract queue scheduler that asynchronously schedules all tasks in a GCD serial queue; - RACTargetQueueScheduler: inherits from RACQueueScheduler, schedules all tasks asynchronously in a serial queue whose target is an arbitrary GCD queue; - RACSubscriptionScheduler: A scheduler used only to schedule subscriptions.Copy the code

Second, common usage

  • Rac_signalForSelector: Replaces the proxy
  • rac_valuesAndChangesForKeyPath: KVO
  • Rac_signalForControlEvents: Listens to events
  • Rac_addObserverForName instead of notification
  • Rac_textSignal: Listens for text changes in a text box
  • Rac_liftSelector: withSignalsFromArray: Signals: when the incoming Signals (array) signal, each signal sendNext at least once, will go to trigger the first selector parameter method.

Common macros

  • RAC(TARGET, [KEYPATH, [NIL_VALUE]]) : Used to bind a property of an object
  • RACObserve(self, name) : Listens on a property of an object and returns a signal.
  • @ weakify (Obj) and @ strongify (Obj)
  • RACTuplePack: Wraps data as RACTuple (tuple class)
  • RACTupleUnpack: Unpack RACTuple (tuple class) into corresponding data
  • RACChannelTo A terminal for bidirectional binding

Four, common operation methods

  • A flattenMap is used to map source signal content into new content.
  • Concat combines signals in a certain order. When multiple signals are sent, sequential signals are received
  • Then is used to connect two signals, and when the first signal is complete, the signal returned by then is connected.
  • Merge Merges multiple signals into one signal, which is called when any signal has a new value
  • ZipWith compresses two signals into a single signal, and the next event of the compressed stream is triggered only when both signals simultaneously emit signal contents and combine the contents of the two signals into a single tuple.
  • CombineLatest: To combine multiple signals and get the latest values of each signal, each combined signal must have sendNext at least once to trigger the combined signal.
  • Reduce aggregation: The content used for signal sending is a tuple, aggregating the values of the signal sending tuple into a value
  • Filter: indicates that you can obtain signals that meet the conditions.
  • Ignore: Signals that ignore certain values.
  • DistinctUntilChanged: signaled when there is a significant change between the previous value and the current value, otherwise ignored.
  • Take: Take N signals from the beginning
  • TakeLast: To get the last N signals, the subscriber must call completion, because only completion knows how many signals there are.
  • TakeUntil :(RACSignal *): Get a signal until a signal execution is complete
  • Skip :(NSUInteger): Several signals are skipped and not accepted.
  • SwitchToLatest: Used to obtain the latest signal sent by signalOfSignals.
  • DoNext: This Block is executed before Next
  • DoCompleted: This Block is executed before sendCompleted is executed
  • Timeout: allows a signal to automatically report an error after a certain period of time.
  • Interval: Sends signals at intervals
  • Delay Delays sending next.
  • Retry retry: On failure, the block in the creation signal is re-executed until it succeeds.
  • Replay: When a signal is subscribed multiple times, the content is played repeatedly
  • Throttle: When a signal is sent frequently, you can use throttling to stop sending signal content for a certain period of time and obtain the latest signal content after a certain period of time.

5. Ui-category (Common summary)

  1. Rac_prepareForReuseSignal: Use relevant UI when reuse is required: MKAnnotationView, UICollectionReusableView, UITableViewCell, UITableViewHeaderFooterView
  2. Rac_buttonClickedSignal: UIActionSheet, UIAlertView
  3. Rac_command: button class, refresh class related commands to replace related UI: UIBarButtonItem, UIButton, UIRefreshControl
  4. Rac_signalForControlEvents: Control event Triggers the related UI: UIControl
  5. Rac_gestureSignal UIGestureRecognizer Event processing signal-related UI: UIGestureRecognizer
  6. Rac_imageSelectedSignal selects the image’s signal-related UI: UIImagePickerController
  7. Rac_textSignal related UIs: UITextField, UITextView
  8. Apis that enable bidirectional binding
- rac_channelForControlEvents: key: nilValue: related UI: the UIControl class - rac_newDateChannelWithNilValue: Related UI: UIDatePicker - rac_newSelectedSegmentIndexChannelWithNilValue: Related UI: UISegmentedControl - rac_newValueChannelWithNilValue: Related UI: UISlider, UIStepper - rac_newOnChannel Related UI: UISwitch - rac_newTextChannel Related UI: UITextFieldCopy the code

6. Foundation-category

  1. NSArray
- RAC_sequence Signal setCopy the code
  1. NSData
-rac_readContentSOfurl: options: Scheduler: has more thread Settings than OCCopy the code
  1. NSDictionary
- RAC_SEQUENCE Not explained - rac_keySequence Key set - rac_valueSequence value setCopy the code
  1. NSEnumerator
- RAC_sequence is not explainedCopy the code
  1. NSFileHandle
- rac_readInBackgroundCopy the code
  1. NSIndexSet
- RAC_sequence is not explainedCopy the code
  1. NSInvocation
- rac_setArgument: atIndex: Sets the argument. - rac_argumentAtIndex Takes the return value of the method associated with one of the arguments - rac_returnValueCopy the code
  1. NSNotificationCenter
- rac_addObserverForName: object: registration notificationCopy the code
  1. NSObject
- rac_willDeallocSignal - RAC_description debug using -rac_observekeypath: options: observer: -rac_liftSelector: withSignals: All signals are executed next. -rac_signalForSelector: Replace a method - rac_signalForSelector:(SEL) Selector fromProtocol: Replace the proxyCopy the code
  1. NSOrderedSet
- RAC_sequence is not explainedCopy the code
  1. NSSet
- RAC_sequence is not explainedCopy the code
  1. NSString
- rac_keyPathComponents access to all part of a path - rac_keyPathByDeletingLastKeyPathComponent last part - delete path Rac_keyPathByDeletingFirstKeyPathComponent delete path in the first part - rac_sequence don't explain (character) - rac_readContentsOfURL: UsedEncoding: Scheduler: compared to OC multi-threaded callCopy the code
  1. NSURLConnection
- rac_sendAsynchronousRequest Initiates asynchronous requestsCopy the code
  1. NSUserDefaults
- rac_channelTerminalForKey Is used for bidirectional binding, which is one endCopy the code