Closed raingerber closed 6 years ago
This has been the worst API decision I've made in this library so far...
I love this change, but to make it we must provide a codemod that will help others refactor.
FYI @jsaterfiel
The accumulator should still exist as it is on all of DataPoint internals, this feature should only change for how the ReducerFunctions
work, meaning only the API expected of the reducer functions should change, nothing more.
Only this part of the code base should change + any tests
IMPORTANT: Please hold off on working on this feature until we have the following tasks done and merged:
yarn install
Problem description:
When executing reducers, the current value is stored on the accumulator, but that can be somewhat awkward in function reducers:
Suggested solution:
Do not store the value on the accumulator. Instead, have two parameters:
value
andcontext
. The value is equivalent to the currentaccumulator.value
, and context will contain the other properties that are stored in the accumulator (such asvalues
,params
, etc). This would simplify our function reducers:This would also make it easier to use third-party functions as DataPoint reducers. For example, say we're trying to use lodash's flatten as a reducer: