Thunk is a function that wraps another function or expression to delay computation. Thunk can also be used to add additional calculations to a function.
Thunks provide lazy evaluation and are widely used in functional programming languages.
If you are looking for Redux Thunk, check out this shot.
Here’s an example of using a thunk myFunction
to delay evaluation of an expression in JavaScript:
// calculation of 1 + 2 is immediate
let x = 1 + 2;
// calculation of 1 + 2 is delayed
// myFunction can be called later to perform the calculation
let myFunction = () => 1 + 2;
Free Resources