From c2cbc4cdaa30ee476a4c3c4022252f625fbef616 Mon Sep 17 00:00:00 2001 From: Laurent Lyaudet Date: Wed, 24 Mar 2021 17:27:49 +0100 Subject: [PATCH] avoid race condition in 06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md Well there is still a chance for a race condition but a smaller one. We would need an atomic "if or set" for isThrottled --- .../09-call-apply-decorators/04-throttle/solution.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md index cf851f77..6950664b 100644 --- a/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md +++ b/1-js/06-advanced-functions/09-call-apply-decorators/04-throttle/solution.md @@ -12,11 +12,10 @@ function throttle(func, ms) { savedThis = this; return; } + isThrottled = true; func.apply(this, arguments); // (1) - isThrottled = true; - setTimeout(function() { isThrottled = false; // (3) if (savedArgs) {