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

Docs for merge option in createAsyncResourceBundle? #25

Open
jvega opened this issue May 29, 2018 · 1 comment
Open

Docs for merge option in createAsyncResourceBundle? #25

jvega opened this issue May 29, 2018 · 1 comment

Comments

@jvega
Copy link

jvega commented May 29, 2018

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
Copy link
Owner

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

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