Reactive = Observables(响应)+ Schedulers(异步).
Extensions = LINQ(语言集成查询)
LINQ:
The Operators of ReactiveX
Operators By Category
Creating Observables
Operators that originate new Observables.
- Create — create an Observable from scratch by calling observer methods programmatically
- Defer — do not create the Observable until the observer subscribes, and create a fresh Observable for each observer
- Empty/Never/Throw — create Observables that have very precise and limited behavior
- From — convert some other object or data structure into an Observable
- Interval — create an Observable that emits a sequence of integers spaced by a particular time interval
- Just — convert an object or a set of objects into an Observable that emits that or those objects
- Range — create an Observable that emits a range of sequential integers
- Repeat — create an Observable that emits a particular item or sequence of items repeatedly
- Start — create an Observable that emits the return value of a function
- Timer — create an Observable that emits a single item after a given delay
Transforming Observables
Operators that transform items that are emitted by an Observable.
- Buffer — periodically gather items from an Observable into bundles and emit these bundles rather than emitting the items one at a time
- FlatMap — transform the items emitted by an Observable into Observables, then flatten the emissions from those into a single Observable
- GroupBy — divide an Observable into a set of Observables that each emit a different group of items from the original Observable, organized by key
- Map — transform the items emitted by an Observable by applying a function to each item
- Scan — apply a function to each item emitted by an Observable, sequentially, and emit each successive value
- Window — periodically subdivide items from an Observable into Observable windows and emit these windows rather than emitting the items one at a time
Filtering Observables
Operators that selectively emit items from a source Observable.
- Debounce — only emit an item from an Observable if a particular timespan has passed without it emitting another item
- Distinct — suppress duplicate items emitted by an Observable
- ElementAt — emit only item n emitted by an Observable
- Filter — emit only those items from an Observable that pass a predicate test
- First — emit only the first item, or the first item that meets a condition, from an Observable
- IgnoreElements — do not emit any items from an Observable but mirror its termination notification
- Last — emit only the last item emitted by an Observable
- Sample — emit the most recent item emitted by an Observable within periodic time intervals
- Skip — suppress the first n items emitted by an Observable
- SkipLast — suppress the last n items emitted by an Observable
- Take — emit only the first n items emitted by an Observable
- TakeLast — emit only the last n items emitted by an Observable
Combining Observables
Operators that work with multiple source Observables to create a single Observable
- And/Then/When — combine sets of items emitted by two or more Observables by means of Pattern and Plan intermediaries
- CombineLatest — when an item is emitted by either of two Observables, combine the latest item emitted by each Observable via a specified function and emit items based on the results of this function
- Join — combine items emitted by two Observables whenever an item from one Observable is emitted during a time window defined according to an item emitted by the other Observable
- Merge — combine multiple Observables into one by merging their emissions
- StartWith — emit a specified sequence of items before beginning to emit the items from the source Observable
- Switch — convert an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables
- Zip — combine the emissions of multiple Observables together via a specified function and emit single items for each combination based on the results of this function
Error Handling Operators
Operators that help to recover from error notifications from an Observable
- Catch — recover from an onError notification by continuing the sequence without error
- Retry — if a source Observable sends an onError notification, resubscribe to it in the hopes that it will complete without error
Observable Utility Operators
A toolbox of useful Operators for working with Observables
- Delay — shift the emissions from an Observable forward in time by a particular amount
- Do — register an action to take upon a variety of Observable lifecycle events
- Materialize/Dematerialize — represent both the items emitted and the notifications sent as emitted items, or reverse this process
- ObserveOn — specify the scheduler on which an observer will observe this Observable
- Serialize — force an Observable to make serialized calls and to be well-behaved
- Subscribe — operate upon the emissions and notifications from an Observable
- SubscribeOn — specify the scheduler an Observable should use when it is subscribed to
- TimeInterval — convert an Observable that emits items into one that emits indications of the amount of time elapsed between those emissions
- Timeout — mirror the source Observable, but issue an error notification if a particular period of time elapses without any emitted items
- Timestamp — attach a timestamp to each item emitted by an Observable
- Using — create a disposable resource that has the same lifespan as the Observable
Conditional and Boolean Operators
Operators that evaluate one or more Observables or items emitted by Observables
- All — determine whether all items emitted by an Observable meet some criteria
- Amb — given two or more source Observables, emit all of the items from only the first of these Observables to emit an item
- Contains — determine whether an Observable emits a particular item or not
- DefaultIfEmpty — emit items from the source Observable, or a default item if the source Observable emits nothing
- SequenceEqual — determine whether two Observables emit the same sequence of items
- SkipUntil — discard items emitted by an Observable until a second Observable emits an item
- SkipWhile — discard items emitted by an Observable until a specified condition becomes false
- TakeUntil — discard items emitted by an Observable after a second Observable emits an item or terminates
- TakeWhile — discard items emitted by an Observable after a specified condition becomes false
Mathematical and Aggregate Operators
Operators that operate on the entire sequence of items emitted by an Observable
- Average — calculates the average of numbers emitted by an Observable and emits this average
- Concat — emit the emissions from two or more Observables without interleaving them
- Count — count the number of items emitted by the source Observable and emit only this value
- Max — determine, and emit, the maximum-valued item emitted by an Observable
- Min — determine, and emit, the minimum-valued item emitted by an Observable
- Reduce — apply a function to each item emitted by an Observable, sequentially, and emit the final value
- Sum — calculate the sum of numbers emitted by an Observable and emit this sum
http://reactivex.io/documentation/operators.html#categorized
Standard Query Operator API[edit]
In what follows, the descriptions of the operators are based on the application of working with collections. Many of the operators take other functions as arguments. These functions may be supplied in the form of a named method or anonymous function.
The set of query operators defined by LINQ is exposed to the user as the Standard Query Operator (SQO) API. The query operators supported by the API are:[3]
Select
Further information: Map (higher-order function)
The Select operator performs a projection on the collection to select interesting aspects of the elements. The user supplies an arbitrary function, in the form of a named or lambda expression, which projects the data members. The function is passed to the operator as a delegate.
Where
Further information: Filter (higher-order function)
The Where operator allows the definition of a set of predicate rules that are evaluated for each object in the collection, while objects that do not match the rule are filtered away. The predicate is supplied to the operator as a delegate.
SelectMany
Further information: Bind (higher-order function)
For a user-provided mapping from collection elements to collections, semantically two steps are performed. First, every element is mapped to its corresponding collection. Second, the result of the first step is flattened by one level. Note: Select and Where are both implementable in terms of SelectMany, as long as singleton and empty collections are available. The translation rules mentioned above still make it mandatory for a LINQ provider to provide the other two operators.
Sum / Min / Max / Average
These operators optionally take a function that retrieves a certain numeric value from each element in the collection and uses it to find the sum, minimum, maximum or average values of all the elements in the collection, respectively. Overloaded versions take no function and act as if the identity is given as the lambda.
Aggregate
Further information: Fold (higher-order function)
A generalized Sum / Min / Max. This operator takes a function that specifies how two values are combined to form an intermediate or the final result. Optionally, a starting value can be supplied, enabling the result type of the aggregation to be arbitrary. Furthermore, a finalization function, taking the aggregation result to yet another value, can be supplied.
Join / GroupJoin
The Join operator performs an inner join on two collections, based on matching keys for objects in each collection. It takes two functions as delegates, one for each collection, that it executes on each object in the collection to extract the key from the object. It also takes another delegate in which the user specifies which data elements, from the two matched elements, should be used to create the resultant object. The GroupJoin operator performs a group join. Like the Select operator, the results of a join are instantiations of a different class, with all the data members of both the types of the source objects, or a subset of them.
Take / TakeWhile
The Take operator selects the first n objects from a collection, while the TakeWhile operator, which takes a predicate, selects those objects that match the predicate (stopping at the first object that doesn't match it).
Skip / SkipWhile
The Skip and SkipWhile operators are complements of Take and TakeWhile - they skip the first n objects from a collection, or those objects that match a predicate (for the case of SkipWhile).
OfType
The OfType operator is used to select the elements of a certain type.
Concat
The Concat operator concatenates two collections.
OrderBy / ThenBy
The OrderBy operator is used to specify the primary sort ordering of the elements in a collection according to some key. The default ordering is in ascending order, to reverse the order, the OrderByDescending operator is to be used. ThenBy and ThenByDescending specifies subsequent ordering of the elements. The function to extract the key value from the object is specified by the user as a delegate.
Reverse
The Reverse operator reverses a collection.
GroupBy
The GroupBy operator takes a function that extracts a key value and returns a collection of IGrouping<Key, Values> objects, for each distinct key value. The IGrouping objects can then be used to enumerate all the objects for a particular key value.
Distinct
The Distinct operator removes duplicate instances of an object from a collection. An overload of the operator takes an equality comparer object which defines the criteria for distinctness.
Union / Intersect / Except
These operators are used to perform a union, intersection and difference operation on two sequences, respectively. Each has an overload which takes an equality comparer object which defines the criteria for element equality.
SequenceEqual
The SequenceEqual operator determines whether all elements in two collections are equal and in the same order.
First / FirstOrDefault / Last / LastOrDefault
These operators take a predicate. The First operator returns the first element for which the predicate yields true, or, if nothing matches, throws an exception. The FirstOrDefault operator is like the First operator except that it returns the default value for the element type (usually a null reference) in case nothing matches the predicate. The last operator retrieves the last element to match the predicate, or throws an exception in case nothing matches. The LastOrDefault returns the default element value if nothing matches.
Single
The Single operator takes a predicate and returns the element that matches the predicate. An exception is thrown, if none or more than one element match the predicate.
SingleOrDefault
The SingleOrDefault operator takes a predicate and return the element that matches the predicate. If more than one element matches the predicate, an exception is thrown. If no element matches the predicate, a default value is returned.
ElementAt
The ElementAt operator retrieves the element at a given index in the collection.
Any / All
The Any operator checks, if there are any elements in the collection matching the predicate. It does not select the element, but returns true if at least one element is matched. An invocation of any without a predicate returns true if the collection non-empty. The All operator returns true if all elements match the predicate.
Contains
The Contains operator checks, if the collection contains a given element.
Count
The Count operator counts the number of elements in the given collection. An overload taking a predicate, counts the number of elements matching the predicate.
https://en.wikipedia.org/wiki/Language_Integrated_Query