Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to only use the second or third callback

Not sure if this is a stupid question but is there a cleaner looking way to only utilise the second/third callback when a function is called?

    uploadTask.on('state_change', ()=>{}, ()=> {}, () => {
        updateCampsite(newCampsiteRef.id, data)
    })

Here I only want to use the third call back but it won't work without the empty functions before it. Is there a better way? Or should I not do this at all?

TIA!

like image 630
mattavero Avatar asked May 07 '26 14:05

mattavero


1 Answers

Pass undefined instead of the empty functions. However, if that gives any error, then pass empty functions. It would be alright even then also.

uploadTask.on('state_change', undefined, undefined, () => {
    updateCampsite(newCampsiteRef.id, data)
})
like image 175
Ravi Garg Avatar answered May 09 '26 04:05

Ravi Garg