Skip to content

Commit a902c8d

Browse files
yjaaidid3lm
authored andcommitted
content(rxjs): give reasons against nested subscriptions
1 parent 716cba2 commit a902c8d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

content/rxjs/avoid-nested-subscriptions.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ fetchProduct(1).subscribe(product => {
2424

2525
We first fetch the product and once the request is resolved we fetch similar products inside the subscribe block of the first, most outer observable.
2626

27-
This is considered to be an anti-pattern or code smell.
27+
This is considered to be an anti-pattern or code smell for the following reasons:
28+
- 👹 it brings us back to callback hell,
29+
- 💔 it breaks Reactive Programming,
30+
- 🐢 it breaks observables laziness,
31+
- 💥 it doesn’t help with subscription management,
32+
- 🤢 it's ugly anyway.
2833

2934
Instead we can use one of the flattening operators to get rid of this code smell and solve it more elegantly:
3035

0 commit comments

Comments
 (0)