Skip to content

Commit 49a8ee2

Browse files
authored
Create no-nested-pipe.md
example in the docs about the growing code face issues with nested pipes for which we require this rule to avoid this complexity
1 parent b9d40ff commit 49a8ee2

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

docs/rules/no-nested-pipe.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Avoid nested `pipe` calls (`no-nested-pipe`)
2+
3+
This rule effects failures if `pipe` is called within a `pipe` handler.
4+
5+
## Rule details
6+
7+
Examples of **incorrect** code for this rule:
8+
9+
```ts
10+
import { of, timer } from "rxjs";
11+
12+
of("searchText1", "searchText2").pipe(switchMap((searchText) => {
13+
return this.callSearchAPI(searchText).pipe(map(response => {
14+
......
15+
......
16+
// considering more lines here
17+
})
18+
})
19+
```
20+
21+
Examples of **correct** code for this rule:
22+
23+
```ts
24+
import { of, timer } from "rxjs";
25+
import { mapTo, mergeMap } from "rxjs/operators";
26+
27+
of("searchText1", "searchText2").pipe(switchMap((searchText) => this.getDisplayResponse(searchText)))
28+
29+
function getDisplayResponse (){
30+
this.callSearchAPI(searchText).pipe(map(response => {
31+
......
32+
......
33+
// considering more lines here
34+
}
35+
36+
```
37+
38+
## Options
39+
40+
This rule has no options.

0 commit comments

Comments
 (0)