Skip to content

Update API to better match Promise spec and add the 'status' prop (closes #35) #37

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

Merged
merged 13 commits into from
Mar 29, 2019

Conversation

ghengeveld
Copy link
Member

@ghengeveld ghengeveld commented Mar 26, 2019

  • Breaking change: Async.Pending was renamed to Async.Initial
  • Added the status prop, which can be one of initial, pending, fulfilled or rejected
  • Added isInitial, isPending, isFulfilled (with alias isResolved), isRejected and isSettled boolean props. isLoading is now an alias for isPending.
  • Added separate TypeScript types for each status, to make various props non-optional.

The pending and fulfilled statuses were chosen over loading and resolved because they better match the terminology in the Promise specification. The Pending helper component was renamed to Initial accordingly, causing a breaking change.

@codecov
Copy link

codecov bot commented Mar 26, 2019

Codecov Report

Merging #37 into master will increase coverage by 1.21%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #37      +/-   ##
==========================================
+ Coverage    98.4%   99.61%   +1.21%     
==========================================
  Files           4        5       +1     
  Lines         502      525      +23     
  Branches      101      112      +11     
==========================================
+ Hits          494      523      +29     
+ Misses          4        2       -2     
+ Partials        4        0       -4
Impacted Files Coverage Δ
src/status.js 100% <100%> (ø)
src/useAsync.js 98.71% <100%> (+6.95%) ⬆️
src/specs.js 99.61% <100%> (ø) ⬆️
src/Async.js 100% <100%> (ø) ⬆️
src/reducer.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 3d450b4...4cdf0ab. Read the comment docs.

@ghengeveld ghengeveld changed the title Add 'status' prop (closes #35) Add 'status' prop and better match Promise spec (closes #35) Mar 27, 2019
@ghengeveld ghengeveld changed the title Add 'status' prop and better match Promise spec (closes #35) Update API to better match Promise spec and add the 'status' prop (closes #35) Mar 27, 2019
@ghengeveld
Copy link
Member Author

This branch is available as a pre-release on npm:

npm install react-async@next

or:

npm install [email protected]

@dhurlburtusa
Copy link
Contributor

@ghengeveld Hello, before you create release 6.x, I wondered if you have considered simplifying some of the properties?

For example, I think it would be nice to just have a single promise property instead of promise and promiseFn. The updated promise property could be a function that returns a Promise or it could be a promise.

Maybe do something similar for watch and watchFn or for deferFn.

@ghengeveld
Copy link
Member Author

Thanks for the suggestion. I've considered this when I introduced watchFn. The reason it's a separate property is that there could also be a legitimate need to watch a function reference itself (rather than invoke it). As for promiseFn, I prefer to mirror deferFn. deferFn itself can't accept a Promise instance as that defeats the purpose, so renaming it to defer would be very confusing.

@ghengeveld ghengeveld merged commit c4fe8eb into master Mar 29, 2019
@ghengeveld ghengeveld deleted the status branch March 29, 2019 10:24
@ghengeveld
Copy link
Member Author

@all-contributors please add @dhurlburtusa for ideas

@allcontributors
Copy link
Contributor

@ghengeveld

I've put up a pull request to add @dhurlburtusa! 🎉

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.

2 participants