Skip to content

Instantly share code, notes, and snippets.

@jack-guy
Last active March 10, 2019 03:07
Show Gist options
  • Save jack-guy/e613325e729958d1bd180f62270edd74 to your computer and use it in GitHub Desktop.
Save jack-guy/e613325e729958d1bd180f62270edd74 to your computer and use it in GitHub Desktop.
import { from, zip } from 'rxjs';
import { scan } from 'rxjs/operators';
const iceCreamFlavors = ['vanilla', 'chocolate', 'strawberry'];
const iceCreamPrices = ['$5.50', '$5.75', '$6.00'];
const iceCreamFlavorToPrice$ = zip(
from(iceCreamFlavors),
from(iceCreamPrices),
).pipe(scan((prev, [flavor, price]) => {
return {
...prev,
[flavor]: price
};
}, {}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment