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

bindCallback incomplete example in docs app #5069

Open
2 of 5 tasks
danielcaldas opened this issue Oct 11, 2019 · 5 comments
Open
2 of 5 tasks

bindCallback incomplete example in docs app #5069

danielcaldas opened this issue Oct 11, 2019 · 5 comments
Labels
docs Issues and PRs related to documentation

Comments

@danielcaldas
Copy link

Documentation Related To Component:

bindCallback

Please check those that apply

  • typo
  • documentation doesn't exist
  • documentation needs clarification
  • error(s) in example
  • needs example

Description Of The Issue

For example Receive an array of arguments passed to a callback to work someFunction callback needs to be called at the end at least once.

So the full correct example IMO should be:

import { bindCallback } from 'rxjs';
 
const someFunction = (a, b, c) => {
  console.log(a); // 5
  console.log(b); // 'some string'
  console.log(c); // {someProperty: 'someValue'}
};
 
const boundSomeFunction = bindCallback(someFunction);
boundSomeFunction().subscribe(values => {
  console.log(values) // [5, 'some string', {someProperty: 'someValue'}]
});

someFunction(5, 'some string', {someProperty: 'someValue'}); // --> missing line
@cartant cartant added the docs Issues and PRs related to documentation label Oct 11, 2019
@cartant
Copy link
Collaborator

cartant commented Oct 12, 2019

That particular example seems incorrect, to me. someFunction doesn't even take a callback, so I don't see how it can be used with bindCallback. IMO, the example should be removed.

@danielcaldas
Copy link
Author

Interesting enough @cartant, the above example logs the expected values. Then, maybe the example does not depicts the correct usage of bindCallback, or?

@cartant
Copy link
Collaborator

cartant commented Oct 13, 2019

Well, it'll log it because the function is called, but there is no callback, so it's pointless and not a good example.

@danielcaldas
Copy link
Author

Ah true, then it's pointless. I agree you should just remove it.

@roddc
Copy link

roddc commented Dec 14, 2021

import { bindCallback } from 'rxjs';

const someFunction = (cb) => {
  cb(5, 'some string', {someProperty: 'someValue'})
};

const boundSomeFunction = bindCallback(someFunction);
boundSomeFunction(12, 10).subscribe(values => {
  console.log(values); // [22, 2]
}); 

The example is wrong

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Issues and PRs related to documentation
Projects
None yet
Development

No branches or pull requests

3 participants