How to rewrite to debounce instead of setTimeout?
You probably need debounce to return a promise.
https://lodash.com/docs/4.17.10#debounce
The behavior should be similar to this https://codesandbox.io/s/wy7z7q5zx5 with an interval of 300 mc
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); const asyncValidation = memoize( async value => { await sleep(500); try { ….. } catch (err) { ….. } });