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 interval to async utilities to supplement post render checks #408

Merged
merged 4 commits into from Jul 23, 2020

Conversation

mpeyper
Copy link
Member

@mpeyper mpeyper commented Jul 16, 2020

What:

Resolves #241
Resolves #393

Why:

If hooks don't render the checks don't run. This makes waiting for side effects or other changes outside of the hook's render lifecycle more difficult.

How:

  • Replace wait with waitFor
  • Introduces an interval option to waitFor and waitForValueToChange
    • check callbacks run after interval time if no renders have occurred since last check

Checklist:

  • Documentation updated
  • Tests
  • Ready to be merged
  • Added myself to contributors table

I'm having some issues generating the docs to check the changes there. There appears to be an issue with one of dependencies of docz but I have yet to look into it more closely. These seems to only be an issue locally. The Netlify preview is generating fine 🤷‍♂️

I'm also thinking about allowing the functionality to by passing a falsy value and using this as the default, making this a non breaking change. We could follow this up with a breaking release that removes wait and changes the default for interval to be 50ms. I've also wanted to change the default timeout to 1000ms for a while now, so I'd probably bundle that into the breaking change too. I've made it opt in for the initial release. Will follow up with a breaking release which enables it by default, adds a default timeout and removed the deprecated wait utility.

@codecov
Copy link

codecov bot commented Jul 16, 2020

Codecov Report

Merging #408 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #408   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            4         4           
  Lines           94       107   +13     
  Branches        15        19    +4     
=========================================
+ Hits            94       107   +13     
Impacted Files Coverage Δ
src/asyncUtils.js 100.00% <100.00%> (ø)

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 3f8bd7b...1ddafa2. Read the comment docs.

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.

wait not triggered on non hook updates Testing the use of Promises with setTimeout in useEffect hook
1 participant