The action spreading rule says that when a function calls an action, it becomes an action too; every caller above it on that path is also an action. This distinguishes reusable calculations from operations with side effects. section 18.18
Use the rule to expose design and testing consequences:
- Calling logAddToCart() inside the calculation add_item() turns add_item() and all its callers into actions. section 9.11
- A caller such as update_shipping_icons() may invoke add_item() merely to calculate a possible cart, causing false logging when no item was added. section 9.11
- Keep the action above the abstraction barrier when the caller captures user intent and already dispatches the required work. section 9.11
Logging a cart addition
Place logAddToCart() in add_item_to_cart(), the add-to-cart click handler, rather than inside add_item(). The handler already performs actions such as updating the DOM and can log the confirmed user intent without contaminating reusable cart calculations. section 9.11
A call-graph diagram makes the upward propagation of action status visible: one action marks every box on the path to the top as an action. section 18.18
