简体   繁体   中英

Javascript: Create call back for function

My requirement is very simple.

 subscribePresence();
 getValidationData();

getValidationData() must be called only when subscribePresence(); finishes its execution. is there any way of doing it ?

Pass getValidationData(); as callback function into first function .

Ex:

function subscribePresence(callback){
  //do your stuffs
  callback();
}

Now call your subscribePresence() as below

subscribePresence(getValidationData);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM