This behavior isn't bad in my particular use-case but it is very unexpected and I'd like to understand why this is happening.
I have the following code running in a sandbox (imported RxJS 6.6.0):
const Rx = rxjs;
const {map,tap, merge, take} = Rx.operators;
const sub = new Rx.ReplaySubject();
sub.next(1);
sub.pipe(
tap(x => {
if (x < 50) sub.next(x*2);
})
)
.subscribe({
next(x) {
console.info('Subscriber A', x)
},
complete() {
console.log('Subscriber A -- Complete!')
}
});
.as-console-wrapper { max-height: 100% !important; top: 0; }
<script src="https://unpkg.com/rxjs@6.6.0/bundles/rxjs.umd.min.js"></script>
I might be doing this entirely the wrong way, but I want intermediate functions to push items back into the original Subject/Observable while also emitting the original item(s) (a feedback loop of sorts). This is the output I'm getting:
Subscriber A64
Subscriber A32
Subscriber A16
Subscriber A8
Subscriber A4
Subscriber A2
Subscriber A1
I would've expected "Subscriber A1" first but it seems like next is adding items to the beginning of the stream instead of the end? Can anyone help make sense of this?