Skip to content

Commit 7d532ee

Browse files
committed
docs: Mention { dispatch: false }.
Closes #57
1 parent d520406 commit 7d532ee

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

docs/rules/no-cyclic-action.md

+26
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,32 @@ actions.pipe(
2222
);
2323
```
2424

25+
This rule can be used with effects _and epics_, so it makes __no attempt__ to discern whether or not dispatching is disabled for an NgRx effect. That is, code like this will effect (🙈) a failure:
26+
27+
```ts
28+
someEffect = createEffect(() =>
29+
this.actions$.pipe(
30+
ofType("SOMETHING"),
31+
tap(() => console.log("do something")),
32+
),
33+
{ dispatch: false }
34+
);
35+
```
36+
37+
Instead, you can use the the RxJS [`ignoreElements`](https://rxjs.dev/api/operators/ignoreElements) operator:
38+
39+
```ts
40+
someEffect = createEffect(() =>
41+
this.actions$.pipe(
42+
ofType("SOMETHING"),
43+
tap(() => console.log("do something")),
44+
ignoreElements()
45+
)
46+
);
47+
```
48+
49+
Or you can use an ESLint [inline comment](https://eslint.org/docs/user-guide/configuring#disabling-rules-with-inline-comments) to disable the rule for a specific effect.
50+
2551
## Options
2652

2753
This rule accepts a single option which is an object with an `observable` property that is a regular expression used to match an effect or epic's actions observable. The default `observable` regular expression should match most effect and epic action sources.

0 commit comments

Comments
 (0)