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
India may review 275 Chinese apps again. What’s g...
Currently, the popularity of WeChat mini-programs...
Soy milk is a popular healthy drink and is also k...
: : : : : : : : : : : : : : :...
|||| Written by reporter Li Li Edited by Ji Jingj...
What's going on as cinemas across the country...
As an observer of the education and training indu...
In the past two years, Xu Huaizhe and Liu Xiong h...
A few days ago, I found a website with less than ...
These days, the safety of the missing 4-year-old ...
Introduction: Although all operations have common...
How do girls react? When lovers and couples kiss,...
Want to know how to completely solve it within 30...
Audit expert: Zhu Guangsi Member of Beijing Scien...