docs(docs-infra): replace wait with debounce for search#67897
docs(docs-infra): replace wait with debounce for search#67897SkyZeroZx wants to merge 1 commit intoangular:mainfrom
wait with debounce for search#67897Conversation
Replaces custom search debounce with `debounced`
41d9dfd to
6038b73
Compare
|
|
||
| let search: Search; | ||
|
|
||
| useAutoTick(); |
There was a problem hiding this comment.
I forgot to run the tests when I made the change.
I updated the test and had to copy some utilities we had in private/testing since I couldn't find an easy way to expose it in adev
There was a problem hiding this comment.
Yeah better to copy what's not part of the public api
| TestBed.inject(ApplicationRef).tick(); | ||
|
|
||
| // The delay from debounced (200ms) | ||
| await timeout(300); |
There was a problem hiding this comment.
you shouldn't await if you use autotick
There was a problem hiding this comment.
IIRC , it's still necessary; autoTick prevented time from accumulating (depending on how many setTimeouts we have, more would accumulate, which would be a waste of resources).
There was a problem hiding this comment.
I would expect a jasmine.clock().tick(300) here.
There was a problem hiding this comment.
We can change it, but it would have to be the equivalent of using a microtask flush , otherwise we'll get an error
jasmine.clock().tick(300)
await Promise.resolve()or using only await timeout(300)
There was a problem hiding this comment.
My issue is that waiting 300ms is too long (as it can add up if we do this on multiple tests).
Having a await Promise.resolve() is fine as it doesn't wait for long.
There was a problem hiding this comment.
I understand, that’s exactly what autoTick is for. It avoids the main drawback of “waiting” and lets the timeout utility (which uses setTimeout under the hood) run synchronously
Using autoTick with timeout is equivalent to
jasmine.clock().tick(300)
await Promise.resolve()
Replaces custom search debounce with
debouncedPR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: N/A
What is the new behavior?
Does this PR introduce a breaking change?
Other information