Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Feb 1, 2022
1 parent 596d514 commit 0f33f58
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ This preset is recommended for projects that use [React](https://reactjs.org) wi
- [effector/no-unnecessary-duplication](rules/no-unnecessary-duplication/no-unnecessary-duplication.md)
- [effector/no-unnecessary-combination](rules/no-unnecessary-combination/no-unnecessary-combination.md)
- [effector/no-useless-methods](rules/no-useless-methods/no-useless-methods.md)
- [effector/no-forward](rules/no-forward/no-forward.md)
- [effector/no-ambiguity-target](rules/no-ambiguity-target/no-ambiguity-target.md)
- [effector/no-duplicate-on](rules/no-duplicate-on/no-duplicate-on.md)
- [effector/no-getState](rules/no-getState/no-getState.md)
Expand Down
23 changes: 23 additions & 0 deletions rules/no-forward/no-forward.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# effector/no-forward

Any `forward` call could be replaced with `sample` call.

```ts
// πŸ‘Ž could be replaced
forward({ from: trigger, to: reaction });

// πŸ‘ makes sense
sample({ clock: trigger, target: reaction });
```

Nice bonus: `sample` is extendable. You can add transformation by `fn` and filtering by `filter`.

```ts
// πŸ‘Ž could be replaced
forward({ from: trigger.map((value) => value.length), to: reaction });

// πŸ‘ makes sense
sample({ clock: trigger, fn: (value) => value.length, target: reaction });
```

πŸ’‘ Tip: [prefer-sample-over-forward-with-mapping](../prefer-sample-over-forward-with-mapping/prefer-sample-over-forward-with-mapping.md) could be superseded by this rule.

0 comments on commit 0f33f58

Please sign in to comment.