Replace p-debounce
by lodash.debounce
#1
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What it does
Fixes eclipse-theia#9139
We used more two libs for debouncing:
p-debounce
andlodash.debounce
,Since
lodash.debounce
is used more thanp-debounce
, we replacep-debounce
bylodash.debounce
where it used before.As
lodash.debounce
returnundefine
where our API ask for a promise type, we have to write adebounceAsync
function to wraplodash.debounce
and return an ideal type.This function is located at
@theia/core/lib/common/promise-util
. Other files where is needed import it.How to test
Some of the functions which use debounce are difficult to test.
it would be better to test the
debounceAsync
function in a test file,or in files like
theia\packages\debug\src\browser\debug-configuration-manager.ts
/theia\packages\core\src\browser\preferences\preference-provider.ts
.The latters run with the start of the application. so we can test that firing the preference is now properly debounced, and will not fire too many times for the same event loop.
Review checklist
Reminder for reviewers