Open brandoniffert opened 7 years ago
Does this work for you?
import { fromEntities } from 'store/selectors'
store.dispatch(resourceCreateRequest('posts', { title: 'foo' })).then((id) => {
const detail = fromEntities.getDetail(store.getState(), 'posts', id)
console.log('Yaay!', detail)
})
Seems like it would but I am trying to use it inside a redux-form onSubmit function so I wouldn't necessarily have access to the current state.
https://github.com/diegohaz/arc/blob/redux-ssr/src-example/containers/PostForm.js#L10
const onSubmit = (data, dispatch) => dispatch(resourceCreateRequest('posts', data))
Trying to do something like that and then have access to the response object from the create/update API call all within onSubmit.
@brandoniffert I'm facing the same issue. Did you solve that someway ? Tks.
From the redux-saga-thunk docs:
I'm using the entities/resource pattern outlined in this repo and it seems that
detail
above is always the id of the resource I am creating/updating. I'm assuming this is so it works with the entities/normalizr pattern? Is there any way to have it return the actual entity object or get access to it somehow from within the resource dispatch promise? I am using resource dispatches a lot in redux-form onSubmits.Thank you