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
Yan Jie's 14-day ultimate waist and abdomen s...
The content discussed in this article is applicab...
Biodiversity Conservation From the Wild to the Ci...
[[144417]] Preface Git is indeed a very good vers...
According to statistics, there are 330 million pa...
From the development of Internet payment to the c...
When the targeting conditions are almost the same...
It is now March, and the official release of Andr...
[[162381]] Recently, many entrepreneurs who want ...
I don’t know if you feel the same as I do recentl...
[Mobile software: Bo Ke Yuan] Astronomers using t...
Let's do an interesting experiment: cross the...
What is the Douyin Blue V certification project? ...
When asked: What is the purpose of holding activi...
There are many controversies about Windows 10, one...