ConfirmeByClient() {
let observable = new Observable(observer => {
this.socket.on('ConfirmeByClient-changed', (data) => {
observer.next(data);
});
});
return observable;
}
The information you showed is insufficient to know the cause. Where are you subscribing to the created observable? Are you calling ConfirmeByClient()
more than once? Try to put some logs to see if that is what is happening.
private varOuter1 = 0;
ConfirmeByClient() {
varOuter1++;
let varInner1 = varOuter1;
let var2 = 0;
let observable = new Observable(observer => {
var2++;
this.socket.on('ConfirmeByClient-changed', (data) => {
console.log('varInner1', varInner1);
console.log('var2', var2);
observer.next(data);
});
});
return observable;
}
See in the console logs if the value of varInner1
or var2
is greater than 1 (it should always be 1).