Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Operator is failing if not proceeded by .distinctUntilChanged #1511

Open
mrpmorris opened this issue Sep 19, 2017 · 0 comments
Open

Operator is failing if not proceeded by .distinctUntilChanged #1511

mrpmorris opened this issue Sep 19, 2017 · 0 comments

Comments

@mrpmorris
Copy link

I'm hoping someone can explain something to me. In this file -> https://github.com/mrpmorris/rxjs-garbage-collect/blob/master/src/rxjs-garbage-collect/src/selectors/StateSelector.ts

...there is a chunk of code that looks like this

    this.observable$ = parent.asObservable()
      .map(x => getProperty(x, this.path))
      .distinctUntilChanged()
      .monitorSubscriberCount(args => this.subscriberCountChanged(args));

My monitorSubscriberCount operator merely calls back the specified method whenever a subscription is added/removed. What I find weird about this though is that I have had to add .distinctUntilChanged in order to make it work. Without it, it seems the .map operator is not remapping the source data into the target.

To see this problem in action clone https://github.com/mrpmorris/rxjs-garbage-collect and then type "ng test" in a command prompt. Note how everything works fine, but then removing the .distinctUntilChanged line in /src/rxjs-garbage-collect/src/selectors/StateSelector.ts breaks everything.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant