RAC Common API (Reprinted memo)

This article and out http://www.code4app.com/blog-721976-195.html

A common class

1, RACSiganl signal class.

RACEmptySignal: null signal, to implement a method RACSignal of + empty;

RACReturnSignal: one yuan signal for realizing the RACSignal + return: Method;

RACDynamicSignal: dynamic signal, using a block - to achieve subscribe behavior, we use createSignal RACSignal the +: is an instance of the class created when the method;

RACErrorSignal: an error signal, is used to achieve RACSignal + error: Method;

RACChannelTerminal: channel terminal, a terminal of the representative RACChannel, to implement two-way binding.

2, RACSubscriber subscribers

3, RACDisposable used to unsubscribe or clean resources, when the signal transmission is completed or sending the wrong time, it will automatically trigger it.

RACSerialDisposable: As the use of disposable containers, may comprise a disposable object, and allows the operation of the disposable objects atomically swapped out;

RACKVOTrampoline: Representative a KVO observation, and observation can be used to stop;

RACCompoundDisposable: it may comprise a plurality of disposable objects, and supports manual addition and removal of disposable objects

RACScopedDisposable: When it is invoked -dispose dealloc method itself.

4, RACSubject signal providers, they can serve as signals, but also to send a signal.

RACGroupedSignal: a packet signal, to implement the grouping function RACSignal;

RACBehaviorSubject: a repeat of the last signal value, when subscribed, it will transmit the last received value to the subscriber;

RACReplaySubject: repeat signal, stored value is sent off, when subscribed, will re-transmit these values ​​to the subscribers.

5, RACTuple tuple type, similar NSArray, for packaging value.

6, RACSequence RAC collections classes

7, RACCommand RAC classes to handle the event, you can put how to handle the event, how the event data transfer, packed into this class, he can easily perform the process of monitoring events.

8, RACMulticastConnection used when a signal, when multiple subscriptions, in order to ensure when creating signals, avoid multiple calls to create a signal block, causing side effects, you can use this class treatment.

9, RACScheduler RAC in the queue, with the GCD package.

RACImmediateScheduler: executing the scheduled task immediately, which is the only one to support synchronous execution scheduler;

RACQueueScheduler: an abstract queue scheduler queue in a serial asynchronous GCD schedule all tasks;

RACTargetQueueScheduler: Inherited from RACQueueScheduler, in an arbitrary order to a target queue GCD serial asynchronous schedule all tasks in the queue;

RACSubscriptionScheduler: a subscription only to schedule scheduler.

Second, the common usage

rac_signalForSelector: instead of agent

rac_valuesAndChangesForKeyPath: KVO

rac_signalForControlEvents: I am listening to events

rac_addObserverForName in lieu of notice

rac_textSignal: listening text box to change the text

rac_liftSelector: withSignalsFromArray: Signals: When incoming Signals (signal array), each signal sendNext have at least once, will go to trigger the first selector parameter method.

Third, the common macro

RAC (TARGET, [KEYPATH, [NIL_VALUE]]): for binding to a property of an object

RACObserve (self, name): monitor a property of an object, returns the signal.

@weakify(Obj)和@strongify(Obj)

RACTuplePack: The data is packaged into RACTuple (tuple class)

RACTupleUnpack: The RACTuple (tuple class) to the corresponding unpacked data

A terminal for two-way binding RACChannelTo

Fourth, the common method of operation

flattenMap map for the contents of the source signals is mapped to the new content.

concat splicing signals combined in a certain order, when a plurality of signals emitted sequential received signal

then used to connect two signals, when the first signal is completed, then the returned signal will be connected.

merge multiple signals into one signal, any signal when there is a new value will call

zipWith the two signals compressed into a signal only when the two signals at the same time send a signal content, and the content of the two signals are combined into a tuple, it will trigger the next event compressed stream.

combineLatest: multiple signals are combined together, and get the latest value of each signal, the combined signal must each have at least once sendNext, the merger will trigger a signal.

reduce the polymerization: a content signal is sent tuple, the tuple value of the signal emitted aggregated into a value

filter: filtering signals, which can satisfy the condition of signal acquisition.

ignore: signal finish certain values ​​ignored.

distinctUntilChanged: When the last value and the current value of the significant changes will send a signal, otherwise it will be ignored.

take: signal N times taken from the start of a total of

takeLast: take the last signal N times, prerequisites, subscribers must call completed because the only complete, you know how many total signal.

takeUntil: (RACSignal *): acquiring a signal to perform signal until completion

skip: (NSUInteger): skip several signals, are not accepted.

switchToLatest: for signalOfSignals (the signal), the signal will sometimes send a signal, will signalOfSignals, get the latest signal signalOfSignals sent.

doNext: Before you perform Next, will first execute the Block

doCompleted: Before performing the sendCompleted, will first execute the Block

timeout: Timeout, allows a signal after a certain period of time, automatic error.

the timing interval: signals at regular intervals

delay transmission delay next.

retry it again: as long as the failure signal will be re-created in block execution until it succeeds.

replay replay: When a signal is repeatedly subscribe, Repeat Play content

throttle throttle: When a signal is sent frequently, you can use the throttle, does not send signal content in a certain period of time, over a period of time to obtain the latest content of the signal emitted.

Five, UI - Category (commonly summary)

1, rac_prepareForReuseSignal: necessary in a multiplex with

Related UI: MKAnnotationView, UICollectionReusableView, UITableViewCell, UITableViewHeaderFooterView

2, rac_buttonClickedSignal: Click Event Trigger

Related UI: UIActionSheet, UIAlertView

3 , rac_command: the Button class, class-related refresh command substitution

Related UI: UIBarButtonItem, UIButton, UIRefreshControl

4, rac_signalForControlEvents: control event trigger

Related UI: UIControl

5, rac_gestureSignal UIGestureRecognizer event processing signal

Related UI: UIGestureRecognizer

6, rac_imageSelectedSignal selected picture signal

Related UI: UIImagePickerController

7、rac_textSignal

Related UI: UITextField, UITextView

8, enabling two-way binding is associated API

rac_channelForControlEvents: key: nilValue:

Related UI: 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: UITextField

Six, Foundation - Category (commonly summary)

1、NSArray

rac_sequence signal set

2、NSData

rac_readContentsOfURL: options: scheduler: a multi-threaded setting than oc

3、NSDictionary

rac_sequence not explain

rac_keySequence key collection

rac_valueSequence value collection

4, NSEnumerator

rac_sequence not explain

5, NSFileHandle

rac_readInBackground see the name EENOW

6, NSIndexSet

rac_sequence not explain

7、NSInvocation

rac_setArgument: atIndex: setting parameters

rac_argumentAtIndex take a parameter

Return value associated method rac_returnValue

8、NSNotificationCenter

rac_addObserverForName: object: Register notice

9、NSObject

When launched destroyed rac_willDeallocSignal target signal

rac_description debug用

rac_observeKeyPath: options: observer: block: an event listener

rac_liftSelector: withSignals: All signals are next in execution

rac_signalForSelector: instead of a method

rac_signalForSelector: (SEL) selector fromProtocol: instead of agent

10, NSOrderedSet

rac_sequence not explain

11, NSSet

rac_sequence not explain

12、NSString

Get all rac_keyPathComponents a path portion

The last part rac_keyPathByDeletingLastKeyPathComponent delete path

rac_keyPathByDeletingFirstKeyPathComponent delete the first part of the path

rac_sequence not explain (character)

rac_readContentsOfURL: usedEncoding: scheduler: OC than the multi-thread calls

13、NSURLConnection

rac_sendAsynchronousRequest asynchronous request

Guess you like

Origin www.cnblogs.com/liuluoxing/p/12187221.html