Javascript: How to execute a code after multiple events have happened? -


i want run function after several events has happened event listener like:

listento(eventa occurred && eventb occured && eventc occurred) {     something. } 

how can accomplish that?

please try promise.all

var p1 = new promise(function(resolve, reject) {    listento(eventa, resolve); });  var p2 = new promise(function(resolve, reject) {    listento(eventb, resolve); }); var p3 = new promise(function(resolve, reject) {   listento(eventc, resolve); });  promise.all([p1, p2, p3]).then(function(value) {    // 3 events triggered.   dosomething... }); 

Comments

Popular posts from this blog

c++ - llvm function pass ReplaceInstWithInst malloc -

java.lang.NoClassDefFoundError When Creating New Android Project -

Decoding a Python 2 `tempfile` with python-future -