Skip to catalogue

reducer

A reducer computes the next state from the current state and an action.

Use this when Related state fields are updated inconsistently by separate event handlers.

without the term

“This form has loading, error, saved and editing flags all updated in different handlers, and after an error they end up contradicting each other. Can you make the updates consistent?”

with the term · How do you ask a model for reducer?

Move these related state transitions into a reducer. Test save, failure, retry, and cancellation without performing network calls inside the reducer.

XBlueskyLinkedIn

What is reducer?

A reducer is a pure function from the current state and an action to the next state. All related transitions live in one place, where you can test them without the network.

Why does reducer matter when vibe coding?

A generated handler can leave contradictory flags after an error.

How do you do reducer?

Describe the allowed actions and test transition sequences independently of side effects.

What goes wrong with reducer?

Using a reducer to centralize side effects instead of state transitions.

adjacent

reviewed

report a correction