redux-machine icon indicating copy to clipboard operation
redux-machine copied to clipboard

Enable diffrent INIT name

Open boazhoch opened this issue 7 years ago • 1 comments

@mheiber Enable diffrent INIT name. what i mean is that - the machine requires a INIT property that holds reducer, i want to be able to initialize the machine with other property name. e.g reduxStateMachine.createMachine({ INITNAME: fn(), nextStatus: fn() })

boazhoch avatar Jan 16 '18 09:01 boazhoch

I feel a little bit silly for publishing a 12-line library, the state machine thing is more of a pattern. You can just do this:

const fetchUsersReducer = (state, action) => {
    switch (state.status) {
    case 'BEGIN':
        return initReducer(state, action)
    case 'IN_PROGRESS':
        return inProgressReducer(state, action)
    default:
        return initReducer(state, action)
    }
}

mheiber avatar Jan 27 '18 22:01 mheiber