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

Add promises support #17

Merged
merged 2 commits into from
Jun 4, 2018
Merged

Add promises support #17

merged 2 commits into from
Jun 4, 2018

Conversation

TiuSh
Copy link
Contributor

@TiuSh TiuSh commented May 8, 2018

Handles promises returned in UpdatesByName and UpdatesForAll functions, and updates form asynchronously (see #16).

@codecov
Copy link

codecov bot commented May 8, 2018

Codecov Report

Merging #17 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #17   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           1      2    +1     
  Lines          28     37    +9     
  Branches        9     12    +3     
=====================================
+ Hits           28     37    +9
Impacted Files Coverage Δ
src/decorator.js 100% <100%> (ø) ⬆️
src/isPromise.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 68ada5a...5761ced. Read the comment docs.

})

if (isPromise(results)) {
results.then(resolved => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem to handle the case when the promise is rejected?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right ! But I took example on the final-form library where the rejected promises are never handled. I think the user of the library should be responsible to catch rejections and restore the chain :

{
  field: 'foo', 
  updates: {
    doubleFoo: (fooValue, allValues) => 
      fetchExternalData(fooValue)
        .then(data => {
          throw 'An error occurred'
        })
        .catch(error => {
          // doubleFoo will be set to `null`
          return null
        })
  }
},

@erikras erikras merged commit 85c4a79 into final-form:master Jun 4, 2018
@erikras
Copy link
Member

erikras commented Jun 4, 2018

Published in v1.2.0.

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

Successfully merging this pull request may close these issues.

3 participants