RACSubscriber
: Indicates the meaning of the subscriber and is used to send a signal, which is a protocol, not a class, as long as the protocol is adhered to and the implementation method can become a subscriber. The signal created by create has a subscriber that helps him send the data.
RACDisposable
: Used to unsubscribe or clean up resources, it will be triggered automatically when the signal is sent or the error is sent.
RACSubject
: The signal provider, who can act as a signal and send a signal.
RACReplaySubject
With the RACSubject
difference:
- Racreplaysubject can send a signal first, in the subscription signal, Racsubject can not.
- If a signal is subscribed once, it needs to send the previous value again and again, using a repeating signal class.
- Racsubject *subject = [racsubject subject];
- [Subject subscribenext:^ (ID x) {
- The information for the subscription is output here X==1
}];
- [Subject sendnext:@ (1)]
- Racreplaysubject *subject = [racreplaysubject subject];
- [Subject sendnext:@ (1)]
- [Subject sendnext:@ (2)]
- [Subject subscribenext:^ (ID x) {
- This outputs the subscription information x==1, and then outputs the subscription information x==2
}];
RACSequence
: A collection class in RAC, used instead of nsarray,nsdictionary, which can be used to quickly iterate through arrays and dictionaries
Nsarray *array = @[@ (0), @ (1), @ (2), @ (3)];
Nsarray *newarray = [[Array.rac_sequence map:^id (id value) {
Return here is an array element of array;
} array]; At this point the NewArray and array have the same elements
RACCommand
: The class used to handle events in RAC, how events are handled, how the data in the event is passed, and packaged into this class, he can easily monitor the execution of events.
RACMulticastConnection
: used when a signal is subscribed multiple times, in order to ensure the creation of a signal, avoid multiple calls to create the block in the signal, causing side effects, you can use this class processing.
RACSignal *signal = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
NSLog(@"发送请求");
[Subscriber sendnext:@ (1)];
return nil;
}];
Racmulticastconnection *connect = [signal publish];
[Connect.signal subscribenext:^ (ID x) {
NSLog (where output is subscribed to the signal x = = 1);
}];
[Connect.signal subscribenext:^ (ID x) {
NSLog (where output is subscribed to the signal x = = 1);
}];
[Connect connect];
RAC Common Classes