Skip to main content

Nesting vs Chaining

tip

Chaining is better than nesting in terms of readability

stream1
.flatMap {
stream2.flatMap {
stream3.flatMap {
stream4
}
}
}
.collect()
const makeBurger = nextStep => {
getBeef(function(beef) {
cookBeef(beef, function(cookedBeef) {
getBuns(function(buns) {
putBeefBetweenBuns(buns, beef, function(burger) {
nextStep(burger);
});
});
});
});
};