I want to emit array items over time (a one second interval between each emit) and when all items have been emitted, repeat over and over.
I know how to do this, but I want to know if there is something more succinct than ..
const MY_ARRAY = ['one','two','three'];
const item$ = Rx.Observable.interval(1000).take(MY_ARRAY.length).repeat().map(x => MY_ARRAY[x]);
item$.subscribe(x => console.log(x));
thanks
output is ..
"one"
"two"
"three"
"one"
"two"
"three"
etc
EDIT:
ATOW, the answers here are summarised as ..
const ARR = ['one', 'two', 'three'];
// TAKE YOUR PICK THEY ALL DO THE SAME
const item$ = Rx.Observable.interval(1000).map(i => ARR[i % ARR.length]);
// const item$ = Rx.Observable.interval(1000).zip(ARR, (a, x) => x).repeat();
// const item$ = Rx.Observable.interval(1000).zip(ARR).repeat().map(x => x[1]);
// const item$ = Rx.Observable.interval(1000).take(ARR.length).repeat().map(i => ARR[i]);
item$.subscribe((x) => {
console.log(x);
});