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

Disable setImmediate event loop yielding in the browser, #50

Merged
merged 3 commits into from
Apr 15, 2020

Conversation

zenflow
Copy link
Contributor

@zenflow zenflow commented Apr 13, 2020

Closes #48

To define isServer we can't use a simple typeof window === 'undefined because Jest provides some kind of shim for window, and we want to run the tests in node.js conditions.

@codecov-io
Copy link

codecov-io commented Apr 13, 2020

Codecov Report

Merging #50 into master will decrease coverage by 0.22%.
The diff coverage is 80.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #50      +/-   ##
==========================================
- Coverage   99.53%   99.30%   -0.23%     
==========================================
  Files           9        9              
  Lines         427      431       +4     
  Branches       68       69       +1     
==========================================
+ Hits          425      428       +3     
- Misses          2        3       +1     
Impacted Files Coverage Δ
src/index.js 97.43% <80.00%> (-2.57%) ⬇️

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 9f0fde2...b93055e. Read the comment docs.

Copy link
Contributor

@kitten kitten left a comment

Choose a reason for hiding this comment

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

Just a suggestion of changing the triggering behaviour. There's one more change you may want to throw in, if you don't mind;

Over in visitor.js we can even stop visitLoop from yielding in the first place by adding SHOULD_YIELD && to this if-statement, which is what interrupts the render-loop:

if (Date.now() - start > YIELD_AFTER_MS) {
return true
}

src/index.js Outdated Show resolved Hide resolved
src/index.js Outdated Show resolved Hide resolved
Co-Authored-By: Phil Plückthun <phil@kitten.sh>
@zenflow
Copy link
Contributor Author

zenflow commented Apr 14, 2020

@kitten Applied suggestions from code review

@zenflow
Copy link
Contributor Author

zenflow commented Apr 14, 2020

Over in visitor.js we can even stop visitLoop from yielding in the first place by adding SHOULD_YIELD && to this if-statement, which is what interrupts the render-loop:

@kitten I'm really not really sure where to move the const SHOULD_YIELD declaration so that it can be imported here. Is a new file src/helpers.js acceptable?

@kitten
Copy link
Contributor

kitten commented Apr 14, 2020

@zenflow given that this is just a two occurrence constant I wouldn’t be too bothered either redefining it or just exporting it from visitor.js. The main logic already depends on visitor.js and on the yielding there, so just sharing it from there isn’t too bad imho.

This way we don’t have to whack in a constants file for a single shared variable 😅

@zenflow
Copy link
Contributor Author

zenflow commented Apr 15, 2020

Over in visitor.js we can even stop visitLoop from yielding in the first place by adding SHOULD_YIELD && to this if-statement, which is what interrupts the render-loop

Done in fc814e2

@kitten kitten merged commit ac5f8dc into FormidableLabs:master Apr 15, 2020
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.

Throws "ReferenceError: setImmediate is not defined" in browser
3 participants