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

distinctUntilChanged broken or API change? #1188

Closed
0x80 opened this issue Mar 30, 2016 · 7 comments
Closed

distinctUntilChanged broken or API change? #1188

0x80 opened this issue Mar 30, 2016 · 7 comments

Comments

@0x80
Copy link

0x80 commented Mar 30, 2016

This example from the docs

/* With key selector */
Observable.of({value: 42}, {value: 42}, {value: 24}, {value: 24})
  .distinctUntilChanged(x => x.value)
  .subscribe(
    function (x) {
      console.log('Next: ', x)
    },
    function (err) {
      console.log('Error: ' + err)
    },
    function () {
      console.log('Completed')
    }
  )

output v4 (as expected):

Next:  { value: 42 }
Next:  { value: 24 }
Completed

output v5:

Next:  { value: 42 }
Completed
@david-driscoll
Copy link
Contributor

the parameters are different between rxjs5 and rxjs4 it looks like.

in rxjs4: distinctUntilChanged = function (keyFn, comparer)
in rxjs5: distinctUntilChanged<T, K>(compare?: (x: K, y: K) => boolean, keySelector?: (x: T) => K)

If this is something you think should be changed, feel free to raise issue over at https://github.com/ReactiveX/rxjs

@0x80
Copy link
Author

0x80 commented Mar 30, 2016

Oops I meant to post this in the v5 repo.

I have a hard time understanding the new API from just the type signature, and the links in the v5 docs are dead. How would you write the above call to distinctUntilChanged with v5 arguments?

@david-driscoll
Copy link
Contributor

the comparer and the key selector are just swapped.

.distinctUntilChanged(x => x.value) -> .distinctUntilChanged(null, x => x.value)

@0x80
Copy link
Author

0x80 commented Mar 30, 2016

Aaah 😃 thanks!

Could you maybe point me to where this is documented?

@david-driscoll
Copy link
Contributor

The docs are a work in progress, but as they get fleshed out they get updated @ http://reactivex.io/rxjs/

@0x80
Copy link
Author

0x80 commented Mar 30, 2016

Ok, I think I better stick to v4 then for now 👍

@spankyed
Copy link

This is poorly documented.

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

3 participants