data-point
data-point copied to clipboard
Add debug reducer helper
trafficstars
Problem description:
There is no way to set breakpoints on path reducers, which makes debugging more difficult.
Suggested solution:
Add a debug reducer helper.
const { debug } = require('data-point').helpers
const reducer = {
// this creates a breakpoint when this reducer is executed,
// which provides a chance to inspect the input data
a: debug('$a')
}
// it should be functionally similar to the code below:
const reducer = {
a: [
(input, acc) => {
debugger
return input
},
'$a'
]
}
debug could also take a function as a second parameter, and this function would be used to set a conditional breakpoint.
const reducer = {
a: debug('$a', input => input === 'some-value')
}
// this would be functionally similar to this code:
const reducer = {
a: [
(input, acc) => {
// this would execute the input => input === 'some-value' function
if (conditionIsTrue(input, acc)) {
debugger
}
return input
},
'$a'
]
}