access the new state with immutable.js when chaining dot notation

时间:2019-04-08 12:54:43

标签: javascript redux state immutable.js reducers

i'm using immutable.js , and i have a redux reducer case where i need to modify a trackslist,

each track has a property of selected which is a boolean .

what this case does is toggling that property and then calculating the duration of those selected tracks combined .

now my prolem is like this : is it possible to acces the new state in the set function after updating it , without using a new variable to store the updated state ?

    var index = state.get("tracksList").findIndex(e => e.get("id") === action.id);

    return state
           .updateIn(["tracksList", index, "selected"], e => !e)

              // i need to acces the new state here
           .set("duration", getDuration(newState.get("tracksList"))); 

0 个答案:

没有答案