AyWa / redux-promise-observable

redux-observable-promise is a plugin for redux-observable. It allows to return a promise after an action as been dispatch, and resolve/reject the promise depending of others action. It can be use for redux-form
MIT License
9 stars 0 forks source link

Return errors #1

Closed patryk4815 closed 6 years ago

patryk4815 commented 7 years ago

How can i return errors to form :) ?

AyWa commented 6 years ago

Sorry I didn't saw your issues, I will take a look tomorrow and come back to you. I will make a pr tomorrow to fix it. I don't resolve, reject the promise with the payload... 😞

AyWa commented 6 years ago

@patryk4815 I fix the issue with the release 0.2.0 an example with redux form:

      <form
        onSubmit={handleSubmit(yourErrorHandler(onFormSubmit))}
      >

with onFormSubmit which is your promiseActionCreator for example:

export const loginRequest = promiseActionCreator(
  loginActionRequest,
  ['LOGIN_SUCCESS', 'LOGIN_FAILURE'],
)

you can now follow the doc of the redux-form: https://redux-form.com/6.0.0-rc.1/examples/submitvalidation/ maybe you want something Like:

f({
    payload,
 }, dispatch).catch(e => {
   // e is the payload of the action
   throw new SubmissionError({ username: e, _error: 'Login failed!' })
 })