When a subject is multicasted, first subscription next event in its observer synchronously, the second subscription will get the reverse sequence of event
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
const test$ = new Subject();
// a subscription
test$.subscribe((current) => {
console.log('a', current);
if(current < 5) {
test$.next(current + 1)
}
})
// b subscription
test$.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
### Reproduction URL
_No response_
### Version
7.2.0
### Environment
_No response_
### Additional context
_No response_
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".