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
Making machines as intelligent as humans has alwa...
PS: Please be mentally prepared before trying! Ha...
From this article, you can learn about the mainst...
On the Internet, we should regard advertising con...
Stones are a very strange existence in the human ...
How many "Apple fans" have not experien...
"Toothache is not a disease, but it is reall...
In the field of organic chemistry, a long-lasting...
Facebook recently authorized Deloitte to quantify...
Recently, the handover ceremony of Gree's high...
It is said that the three treasures of losers are...
According to the report of World Salt Reduction W...
Produced by: Science Popularization China Author:...
March 14, 2023 The 13th Five-Year Plan for Nation...
In the minds of entrepreneurs in the mobile Inter...