Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Type ExampleOfCallback = (params: any, callback: () => void) => void
Then applied
Const example: ExampleOfCallback = (params, callback) => {
Console.log(‘params’, params)
callback()
}
Example({}, () => console.log(‘callback called’)) -
you want to trigger some function after some other function completes execution, if your function is asynchronous, you can't just write it one after another as it will not wait for finishing, so, you pass your function as parameter which is triggered after execution.
Other option is async/await which is much cleaner.
Related Rants
how do callback functions work in js?
question
js