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: resultSelector destructuring callback argument if it's array #7424

Open
ArtemNikolaev opened this issue Jan 5, 2024 · 1 comment

Comments

@ArtemNikolaev
Copy link

Describe the bug

bindCallback(fnCb, resultSelector);

if callback in fnCb looks like cb(arg1); - resultSelector will work as function (arg1) {...}
if callback in fnCb looks like cb(arg1, arg2, ..., argN) - resultSelector will work as function (arg1, arg2, ..., argN) {...}
This is expected behavior, the problem is:

if callback in fnCb looks like cb( [ val1, val2, ..., valN ])(single argument, which is array) - resultSelector will work as function (val1, val2, ..., valN) {...}

Expected behavior

for callback call which looks like cb( [ val1, val2, ..., valN ])(single argument, which is array) - resultSelector should work like
funciton (arg1) {...}, where arg1 is [ val1, val2, ..., valN ]

Reproduction code

function fnCallback4(val, cb) {
    cb(['otherFromCallback', val, 'otherFromCallback']);
}
function resultSelector4(arg1, arg2, arg3) {
    return ['otherFromResultSelector', arg1, arg2, arg3, 'otherFromResultSelector'];
}

const bC4 = bindCallback(fnCallback3, resultSelector3);
bC4('bla').subscribe(console.log);

Reproduction URL

No response

Version

7.8.1

Environment

nodejs 21.4.0

Additional context

No response

@ArtemNikolaev
Copy link
Author

Also see same behaviour on bindNodeCallback

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

No branches or pull requests

1 participant