Filter operator function of RxJava2.0 and filter operator of rxjava2.0
Filter OPERATOR: filters or filters events sent by the observer and events accepted by the observer.
1. filter events based on conditions
(1), Filter ()
Purpose: Filter specific conditions.
Example:
Running result:
(2) ofType
Purpose: filter data of a specific data type.
Instance:
Running result:
(3) skip () skip a forward event/skipLast () skip a reverse event
Running result:
(4) distinct ()/distinctUntilChanged ()
Purpose: Filter repeated events/continuous recurring events in the event sequence.
Example of distinct:
Running result:
DistinctUntilChanged (): removes the example of continuous repetition.
Running result:
2. filter events based on the specified number of events
(1) take: specifies the maximum number of events that an observer can accept.
Running result:
(2) takeLast
Purpose: Specify the last few events that the observer can only receive.
Running result:
3. filter conditions based on the specified time
(1) throttleFirst
Purpose: within a certain period of time, only the first event within the specified period of time can be sent.
Running result:
(2) throttleLast
Purpose: only the last event of the specified time period can be sent.
Running result:
(3) sample: within a certain period of time, only the latest (last) events within the specified period of time are sent, which is similar to throttleLast ().
(4) throttleWithTimeout ()/debounce ()
Purpose: when a data event is sent, if the interval between two events is less than the specified time, the previous data will be lost, the last data is sent until no new data is sent within the specified time.
Running result: