I have two classes named say A
and B
both has two methods named start
and done
. I create instance of both the classes.
var a = new A();
var b = new B();
I bind start
event on b
and done
event to a
.
a
emits start
so b.start
is called, and b
emits done
so a.done
is called. and this process continues until a.done
decides and stops emitting start
. It works fine till there is only one instance of B
.
When I create two instances of B
. b.start
fires one extra time than it should.
and interestingly, when I emit done
within a setTimeout()
of zero ms, it works perfectly fine.
I am not sure if I explained it correctly. Please suggest what could be the cause. I tried lots of stuff which didn't give me a reason as why adding setTimeout
helps.