How to emit items from list with delay between each item?

Marian Paździoch

I want to emit items from list and between each of emission I want a delay. I've tried this:

final Subscription subscription = Observable.from(listOfItems)
    .delay(2000, TimeUnit.MILLISECONDS)
    .subscribe(new Subscriber<String>() {
        @Override
        public void onCompleted() {

        }

        @Override
        public void onError(Throwable e) {

        }

        @Override
        public void onNext(String sss) {
        }
    });

but it just delays the start of emission, not emission of each item.

m.ostroverkhov

You can do it as follows:

List<Integer> listOfItems = Arrays.asList(1, 2, 3);
        Observable.from(listOfItems)
                .zipWith(Observable.interval(2, TimeUnit.SECONDS), (item, notUsed) -> item)
                .subscribe(System.out::println);

If you want delay before first emission use Observable.interval(initialDelay, delay, TimeUnit)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to emit items from list with delay between each item?

From Dev

How to emit items from a Collection with delay in RxJava?

From Dev

How to emit items from a Collection with delay in RxJava?

From Dev

rxjava delay: How to get variable delay on each item emitted from a list?

From Dev

Taking a list of items and displaying a value from each item as a string

From Dev

making a list of items combining each item from several lists

From Dev

SASS, animate each list items with a delay

From Java

RxJava delay for each item of list emitted

From Dev

How can I target each item in a list with collapsible items?

From Dev

How can I target each item in a list with collapsible items?

From Dev

List of unique items from two lists with duplicates between each other

From Dev

How to emit a final item after all the items in the Flowable are emitted

From Dev

How to call an item from a list of items in c#

From Dev

How to insert delay between each requests in Jmeter

From Dev

How to map a list of items into another list of buckets, given a key for each item?

From Dev

Delay items emission until item is emitted from another observable

From Dev

Create a Tree from a list of items, when each item contains a reference to its parent

From Dev

How remove item from RecyclerView with delay

From Dev

How to group items in array by summary each item

From Dev

How to specify space between each list item and space before/after the whole list

From Dev

How to delay jQuery Waypoint for each item in order to create staggering effect?

From Dev

How to show dynamic caption from a row of items where each item is 4 cell apart?

From Dev

How to remove it items from one Excel list, if the same item exist in different list

From Dev

how to remove item from list in JavaScript using angularjs, without loading previous items in list

From Dev

set image for each item in a list of items, during fragment on Create view

From Dev

How to use Promise.all to loop through a list of API calls while also having a delay between each call?

From Dev

How to add items to the item List in PayPal API

From Dev

extract the integer and unicodes from each item in the list

From Dev

find the newest record for each item from a list

Related Related

  1. 1

    How to emit items from list with delay between each item?

  2. 2

    How to emit items from a Collection with delay in RxJava?

  3. 3

    How to emit items from a Collection with delay in RxJava?

  4. 4

    rxjava delay: How to get variable delay on each item emitted from a list?

  5. 5

    Taking a list of items and displaying a value from each item as a string

  6. 6

    making a list of items combining each item from several lists

  7. 7

    SASS, animate each list items with a delay

  8. 8

    RxJava delay for each item of list emitted

  9. 9

    How can I target each item in a list with collapsible items?

  10. 10

    How can I target each item in a list with collapsible items?

  11. 11

    List of unique items from two lists with duplicates between each other

  12. 12

    How to emit a final item after all the items in the Flowable are emitted

  13. 13

    How to call an item from a list of items in c#

  14. 14

    How to insert delay between each requests in Jmeter

  15. 15

    How to map a list of items into another list of buckets, given a key for each item?

  16. 16

    Delay items emission until item is emitted from another observable

  17. 17

    Create a Tree from a list of items, when each item contains a reference to its parent

  18. 18

    How remove item from RecyclerView with delay

  19. 19

    How to group items in array by summary each item

  20. 20

    How to specify space between each list item and space before/after the whole list

  21. 21

    How to delay jQuery Waypoint for each item in order to create staggering effect?

  22. 22

    How to show dynamic caption from a row of items where each item is 4 cell apart?

  23. 23

    How to remove it items from one Excel list, if the same item exist in different list

  24. 24

    how to remove item from list in JavaScript using angularjs, without loading previous items in list

  25. 25

    set image for each item in a list of items, during fragment on Create view

  26. 26

    How to use Promise.all to loop through a list of API calls while also having a delay between each call?

  27. 27

    How to add items to the item List in PayPal API

  28. 28

    extract the integer and unicodes from each item in the list

  29. 29

    find the newest record for each item from a list

HotTag

Archive