-
Notifications
You must be signed in to change notification settings - Fork 80
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Enable flush timing to be controlled from the host. #363
Conversation
fa627fc
to
5ed02da
Compare
tests/autorun-test.ts
Outdated
@@ -5,6 +5,14 @@ import lolex from 'lolex'; | |||
const SET_TIMEOUT = setTimeout; | |||
let fakeClock; | |||
|
|||
function flushMicrotasks() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't this flush macro task, as the promise wont resolve until setTimeout(resolve, 0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s to ensure the current event frame’s microtask queue is flushed by resolving in a macro task
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does that make sense @stefanpenner, I can rename if you'd prefer still just give me an alternate...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, I understand what it does.
The name is off, it isn’t flush microtasks, it’s wait for some near future macro task.
Nothing prevents other unexpected work from sneaking in between so the “flush” word is misleading
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy to change it, what would you like it to be named?
Some possibilities:
escapeMicrotaskQueue
stefsMagicalFutureMacroTask
(😜)waitForNextMacroTask
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, I just renamed to escapeCurrentMicrotaskQueue
which actually seems a bit more descriptive as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spellcheck test names, precedence is spelled wrong.
79df7ea
to
6986666
Compare
Fixed up linting failures and misspelling. |
* Changes `_autorun` into a boolean * Adds a new `flush` option to the backburner options which allows the host to either immediately flush (which would equal the prior behavior) via microtasks, **OR** flush "sometime later" * Adds tests to ensure execution order Co-authored-by: Kris Selden <kris.selden@gmail.com>
6986666
to
a29d59e
Compare
_autorun
into a booleanflush
option to the backburner options which allows the host to either immediately flush (which would equal the prior behavior) via microtasks, OR flush "sometime later"Paired with @krisselden