What does it mean in programming or developing?
All this two approach provide restrictions for immediately run actions .
When we typing something in input field for example making search request, we want to wait when typing will be finished, because we don’t want to send requests after every typed letter in input field, firing requests
1.When we start typing from the first letter we should define the timer which will start countdown immediately and blocking utilize function which will make search request.
2.If typing continues we should reset timer to initial state and blocking to fire function again.
3.After timer reached out and no typing event will be detected from search input – function should be called
Limiting function call during period of time.For example could be used when fetch some data from remote service to avoid DDOS-ing remote service.
1.When some action starts, we will call function and set timer for next call, blocking next calls until the timer reached out and we will able call function again.
2.When we call function in blocking time – we will get nothing, after time reached out also.
3.We can make call function again after timer reached out.
Main difference between throttling and debouncing
Debouncing – blocking immediately function calling during some period of time and postpone function call when action will be repeated during blocking period of time.
Throttling – limiting repeatedly calling function during some period of time with immediately first function call.