You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a subject is multicasted, first subscription next event in its observer synchronously, the second subscription will get the reverse sequence of event
#6976
Open
sanmaopep opened this issue
May 23, 2022
· 1 comment
When a subject is subscribed into two subscription: a & b
In subscription a:
console a value
next a value synchronously and recursively (for instance 1, 2, 3, 4, 5)
In subscription b:
console a value
and subject next a value 1 so 1 will be multicasted to a & b
And subscription a will console 1, 2, 3, 4, 5, which meets the demand
But subscription b will console 5, 4, 3, 2, 1, in this case the normal event sequence is reversed
Expected behavior
subscription a & b console the same event sequence
subscription a will console 1, 2, 3, 4, 5
subscription b will also console 1, 2, 3, 4, 5
Reproduction code
consttest$=newSubject();// a subscriptiontest$.subscribe((current)=>{console.log('a',current);if(current<5){test$.next(current+1)}})// b subscriptiontest$.subscribe((current)=>{console.log('b',current);})test$.next(1);// a 1// a 2// a 3// a 4// a 5// b 5// b 4// b 3// b 2// b 1
Looks like current behavior is correct. "next" is called synchronously from "a", and because all its callbacks are called synchronously too, all these calls take place before first callback call in "b".
Describe the bug
When a subject is subscribed into two subscription: a & b
In subscription a:
console a value
next a value synchronously and recursively (for instance 1, 2, 3, 4, 5)
In subscription b:
console a value
and subject next a value 1 so 1 will be multicasted to a & b
And subscription a will console 1, 2, 3, 4, 5, which meets the demand
But subscription b will console 5, 4, 3, 2, 1, in this case the normal event sequence is reversed
Expected behavior
subscription a & b console the same event sequence
subscription a will console 1, 2, 3, 4, 5
subscription b will also console 1, 2, 3, 4, 5
Reproduction code
The text was updated successfully, but these errors were encountered: