Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable diffrent INIT name #15

Open
boazhoch opened this issue Jan 16, 2018 · 1 comment
Open

Enable diffrent INIT name #15

boazhoch opened this issue Jan 16, 2018 · 1 comment

Comments

@boazhoch
Copy link

boazhoch commented Jan 16, 2018

@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() })

@mheiber
Copy link
Owner

mheiber commented Jan 27, 2018

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)
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants