Skip to content

Instantly share code, notes, and snippets.

@ThomasKruegl
Created February 10, 2021 15:09
Show Gist options
  • Save ThomasKruegl/cb0543c48e5a252925393c0bd2acef2e to your computer and use it in GitHub Desktop.
Save ThomasKruegl/cb0543c48e5a252925393c0bd2acef2e to your computer and use it in GitHub Desktop.
const { interval, of, from } = Rx;
const { take, delay, map, switchMap, groupBy, mergeMap, toArray } = RxOperators;
const foo1 = {
items: []
};
const foo2 = {
items: [1,2,3]
};
const foo3 = {
items: [1,2,2]
};
const foo4 = {
items: [1,1,1,2,2,2,2]
};
const input = [foo1, foo2, foo3, foo4];
interval(1000)
.pipe(
take(4),
map(i => input[i]),
map(obj => obj.items),
switchMap( arr => from(arr)),
groupBy(num => num),
// mergeMap(group => group.pipe(toArray()))
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment