One of my goals is to promisify the onSubmit handling in my submitForm for redux form.
You can find a similar example here.
submitForm = () => {
return this.props.submituserForm()
.then(() => { console.log('test') })
.catch(() => { console.log('error') })
}
-----------------------------------
const mapDispatchToProps = (dispatch) => {
// I aim to convert submituserForm into a promise-like function mimicking the sleep
// function featured below
return {
submituserForm: () => dispatch(submit())
}
};
////////////////////////////////////////////////////
// This section is functioning correctly
const submit = () => {
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms));
// Introducing server latency simulation
return sleep(5000)
.then(() => { console.log('test') };
}