3 ms·
In that context, I don't understand the word reducer.
by frenchman99 3y ago
In that context, I don't understand the word reducer.
- mst 3y agoThe reducer takes objects representing mutations and applies the appropriate changes to the state. It's called a reducer because it operates like a reduce/fold operation, in that if you take a given state and an ordered list of mutations, you'll end up with a new state out the other side, much like 'let newState = list.reduce(reducer, initialState)' would in JS. The reducer model is how Elm's state management works, and Redux's, and is what allow replaying of subsequent changes against a previous state to get to a current state (which enables, amongst other things, some the features of those systems' respective dev tools). The article links to the (nearly trivial) reducer for the todo example, which is on github here: https://github.com/orbitinghail/sqlsync/blob/ba762ce2a10afbb8d7856d26ce5b2f108716e38d/demo/demo-reducer/src/lib.rs https://github.com/orbitinghail/sqlsync/blob/ba762ce2a10afbb...