Skip to content

Instantly share code, notes, and snippets.

@larsw
Created August 3, 2017 18:13
Show Gist options
  • Save larsw/85bab4f99fed8452187ccc09dde56495 to your computer and use it in GitHub Desktop.
Save larsw/85bab4f99fed8452187ccc09dde56495 to your computer and use it in GitHub Desktop.
rxjs groupBy() / flatMap() / group.reduce() problem
//
// yields a stream of objects.
//
observable.subscribe(x => console.log(x))
//
// returns:
// []
// []
// []
// ...
// []
observable.groupBy(x => x.navntype)
.flatMap(group => group.reduce((acc, curr) => [...acc, ...curr], []))
.subscribe(x => console.log(x))
@larsw
Copy link
Author

larsw commented Aug 3, 2017

all the objects in the observable has the 'navnetype' property.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment