Skip to content

ReplaySubject subscription handler is called before it is subscribed #2044

@ventsislav-georgiev

Description

@ventsislav-georgiev

RxJS version:
rxjs@5.0.0-rc.1

Code to reproduce:

let subject = new Rx.ReplaySubject();
subject.next(1);
subject.subscribe(function (data) {
  console.log(data);
  if (data < 3) { data++; subject.next(data); }
});

Expected behavior:
Output: 1, 2, 3

Actual behavior:
Output: 1

Additional information:
This works properly in RxJS v4

It seems that the issue comes from this code: https://github.com/ReactiveX/rxjs/blob/master/src/ReplaySubject.ts#L40
Where we first call the subsrcibe handler with the previous values, before we actually subscribe him for next values.

Metadata

Metadata

Assignees

Labels

bugConfirmed bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions