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
"On the eve of the Qingming Festival, parts ...
Microsoft pointed out at the Windows 10 launch ev...
Diamond is the hardest substance known in nature....
When a product is in its early stages, the produc...
The prevalence of self-media has made us realize ...
When creating content for a public account, there...
On January 9, the Japan Automobile Importers Asso...
There is no fixed price for the production of Zha...
In the past two years, information flow advertisi...
On November 11, 2014, WeChat officially added a h...
People often ask me how to promote a website? Tod...
As a post-90s campus entrepreneur with no resourc...
Editor | Yifeng Produced by | 51CTO Technology St...
2021 is about to pass This year Someone is coming...
The National Day holiday is finally coming. I hav...