How would I interact with stateful API if the states in redux should be immutable?

Viewed 186

So in this app, I am using the MediaRecorder api (https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder). I am trying to use React-Redux as a framework for the site. The following is a simplified version of my reducer to illustrate my question:

(state = {}, action) => {
    switch(action.type){
        case "START_RECORDING":
            return new MediaRecorder(...).start();
        case "STOP_RECORDING":
            state.stop(); <--- is this ok?
            return {};
    }
    return state;
})

So I read that the redux state should be immutable. However, I have to somehow stop the media recorder so that it stops recording stuff. Is this state.stop() ok?

1 Answers
Related