Skip to content

Latest commit

 

History

History
23 lines (16 loc) · 703 Bytes

no-forward.md

File metadata and controls

23 lines (16 loc) · 703 Bytes

effector/no-forward

Any forward call could be replaced with sample call.

// 👎 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.

// 👎 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 could be superseded by this rule.