Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

‘distinct’ can't work as the description in tutorials #3069

Closed
liuyunwei opened this issue Nov 14, 2017 · 4 comments
Closed

‘distinct’ can't work as the description in tutorials #3069

liuyunwei opened this issue Nov 14, 2017 · 4 comments

Comments

@liuyunwei
Copy link

the test code in http://reactivex.io/rxjs/manual/tutorial.html#producing-values

// typing "hello world"
var input = Rx.Observable.fromEvent(document.querySelector('input'), 'input');
// Only pass unique values through
input.pluck('target', 'value').distinct()
  .subscribe(value => console.log(value)); // "helo wrd"

When I type "hello world", it prints "hello world", is there anything wrong?

RxJS version:
5.0.3
Code to reproduce:
copy the demo codes to make a online demo
http://reactivex.io/rxjs/manual/tutorial.html#producing-values
http://jsbin.com/kiwumisoja/edit?html,js,console,output
Expected behavior:
http://reactivex.io/rxjs/manual/tutorial.html#producing-values
print "helo wrd" in console tab
Actual behavior:
print "hello world"
Additional information:

@martinsik
Copy link
Contributor

@liuyunwei I think it works as expected. When you write for example "Hello" then clear the input and start writing the same "Hello" again it'll be ignored as expected. But if you wrote "Hello2" you'll see a new log in the console "Hello2" because you haven't written this term yet.

@SangKa
Copy link
Contributor

SangKa commented Dec 20, 2017

The operators are fine, but the tutorials would confuse some guy.
The following sample code is better for illuminate distinct or distinctUntilChanged:

Rx.Observable
  .of('h', 'e', 'l', 'l', 'o', ' ', 'w', 'o', 'r', 'l', 'd')
  .distinct()
  .subscribe(x => console.log(x));  // h, e, l, o,  , w, r, d

@dengwanc
Copy link

as far as i'm concerned,

  1. the doc is totally confuse new one
  2. in this case simplely
 input.pluck('target', 'value')
  .map(value => distinct(value)) // distinct need implement
  .subscribe(value => console.log(value)); // "helo wrd"

RxJS is not doing every thing, focus on the import part lodash for async

@benlesh
Copy link
Member

benlesh commented Oct 2, 2019

This is outdated it seems.

@benlesh benlesh closed this as completed Oct 2, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 1, 2019
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

5 participants