This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<style> | |
.item { | |
display: block; | |
} | |
</style> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cbCounter = 0 | |
function finalCb(){ | |
// Do something when all CBs are called | |
} | |
function wrapCb(cb, context){ | |
cbCounter++; | |
return function(){ // context is optional, if you need to have the `this` changed for the CB | |
cb && cb.call(context || this); // so CB isn't mandatory | |
cbCounter--; |