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

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -