Search code examples
reactive-programmingrxjsreactive-extensions-js

Create infinite repeatable Observable from array


Let's say I have an array items

I know I can create an observable from this array using

Rx.Observable.fromArray(items)

How do I create a lazily infinitely repeating observable from this (i.e.: repeating the items as long as they are being requested)?

Tried

Rx.Observable.fromArray(items).repeat()

But this doesn't execute lazily and therefor locks up the browser.


Solution

  • You cannot do this with an Observable. You way want to look at using an Enumerable.

    The Enumerable flavor of Reactive Extensions is known as Interective Extensions.