I am currently following along with a react/redux tutorial that has me using ES6 and immutable.js both of which I am new to.
In the following function:
export function vote(state, entry) {
return state.updateIn(
['vote', 'tally', entry],
0,
tally => tally + 1
);
}
This line: tally => tally + 1
Has me a bit confused.
Is this a feature of ES6 or immutable? I understand that the result of this function will be that the current value of tally
will be incremented by 1, but the syntax is unusual to me.
In the immutable docs this line is referred to as the updater
, but i don't not see a description of it and I do not understand if it is then a feature of ES6 itself. If it is whats another example of this being used and whats a non ES6 example?
I am sorry if this is a bit confusing I am not sure how else to word this question.
By the way the state map looks like this:
const state = Map({
vote: Map({
pair: List.of('Trainspotting', '28 Days Later'),
tally: Map({
'Trainspotting': 3,
'28 Days Later': 2
})
}),