HenrikJoreteg / redux-bundler

Compose a Redux store out of smaller bundles of functionality.
https://reduxbundler.com
583 stars 46 forks source link

Docs for merge option in createAsyncResourceBundle? #25

Open jvega opened 6 years ago

jvega commented 6 years ago

I found this option in the bundle but I don't find any doc

Exists a better way to set this option ...

const promise = ({ apiFetch }) => {
    return apiFetch('resources')
}
const bundle = createAsyncResourceBundle({
    name: 'resource',
    getPromise: promise
})
bundle.doFetchResource =() => args => {
    const { dispatch } = args
    dispatch({ type: 'RESOURCE_FETCH_STARTED' })
    return promise(args).then(
        payload => {
            dispatch({
                type: 'RESOURCE_FETCH_FINISHED',
                payload,
                merge: true // <- option
            })
        },
        error => {
            dispatch({ type: 'RESOURCE_FETCH_FAILED', error })
        }
    )
}
HenrikJoreteg commented 6 years ago

@jvega good point, would be happy for a PR from someone adding this.