Continued from previous article Take The Take operator modifies the behavior of an Observable to return only the first N items of data, then emit a completion notification and ignore the remaining data.
Output log information
Like skip, take also has two other overloaded methods: take(long time, TimeUnit unit) and take(long time, TimeUnit unit, Scheduler scheduler), which are executed on the computation scheduler by default. take also has a variant operator TakeLast, takeLastBuffer. The specific execution effect can be coded by yourself. Debounce This operator means that a data is emitted only when no data is emitted after a specified period of time. It may sound a bit confusing. You can understand it as filtering the results generated by the source Observable interval. If no other results are generated within this specified interval, the result is submitted to the subscriber, otherwise the result is ignored. The principle is a bit like optical image stabilization. On the code
Output information
The output data may not be the same, it may start from 5. Distinct This is relatively easy to understand. It filters out duplicate data and only allows data items that have not yet been emitted to pass. Sample Code
Output log information
ElementAt This operator gets the data item at the specified index position of the data sequence emitted by the original Observable, and then emits it as its own first data. Pass it a 0-based index value, and it will emit the value of the corresponding index position of the original Observable data sequence. If the value you pass to elementAt is 4, it will emit the data of the 5th item. The following example code
Output log information
IgnoreElements The operator suppresses all data emitted by the original Observable and only allows its termination notification (onError or onCompleted) to pass through. The onNext() method will not be executed using this operator.
After execution, only onCompleted will be output. The effect of this operator is just like the empty() method to create an empty Observable, and only the onCompleted() method will be executed. The difference is that ignoreElements processes the data source, while empty() creates an Observable. |
<<: RxJava Operator Series 3 (Part 1)
>>: A collection of ViewHolder tool classes
Why develop a WeChat applet development company? ...
Editor’s Note: Protecting biodiversity and ensuri...
Computer programming and gene synthesis may seem ...
Only those who are losing weight can understand t...
External links refer to links from other websites...
In the field of smart phones, iPhone user loyalty...
The opening and popularity of Universal Studios B...
© Wellcome Collection Leviathan Press: Sleep para...
Ten years ago, the interaction method of smartpho...
On December 10, Samsung and Huawei Honor both lau...
Brand Name: MuseMarry After one week of launch, c...
When we enter the daily experience design process...
The love of beauty has existed since ancient times...
De Ge's Stock Discussion: Thirteen Short-term...
For user operations personnel, if the product has...