ReactiveX/rxjs

bindCallback: resultSelector destructuring callback argument if it's array

ArtemNikolaev opened this issue · 1 comments

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

Also see same behaviour on bindNodeCallback