Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Rxjs扫描的功能体中有这么多ComA?_Javascript_Rxjs - Fatal编程技术网

Javascript Rxjs扫描的功能体中有这么多ComA?

Javascript Rxjs扫描的功能体中有这么多ComA?,javascript,rxjs,Javascript,Rxjs,我一直在看这个代码。 const game$=CombineTest(键$,字母$).pipe( 扫描 ((说明,[键,字母])=>( letters.ltrs[letters.ltrs.length-1]&& letters.ltrs[letters.ltrs.length-1]。letter==键 ((state.score=state.score+1),letters.ltrs.pop()) :不, state.score>0&&state.score%levelChangeThresh

我一直在看这个代码。

const game$=CombineTest(键$,字母$).pipe(
扫描<[字符串,字母],
州>
((说明,[键,字母])=>(
letters.ltrs[letters.ltrs.length-1]&&
letters.ltrs[letters.ltrs.length-1]。letter==键
((state.score=state.score+1),letters.ltrs.pop())
:不,
state.score>0&&state.score%levelChangeThreshold==0
((letters.ltrs=[]),
(state.level=state.level+1),
(state.score=state.score+1),
intervalSubject.next(letters.intrvl-speedAdjust))
:不,
{score:state.score,字母:letters.ltrs,级别:state.level}
),
{分数:0,字母:[],级别:1}),
takeWhile(state=>state.letters.length
这是我看到的另一个代码,它也使用了很多Coma

const game$ = combineLatest(state$, player$)
  .pipe(
    scan<[State, [number[][], Key]], [State, [number[][], Key]]>(
      ([state, [brick, key]]) => (
        handleKeyPress(state, brick, key),
        brick = rotate(state, brick, key),
        brick = collide(state, brick),
        score(state),
        resetKey(key),
        [state, [brick, key]]
      )),
    tap(([state, [brick, key]]) => render(state, brick)),
    takeWhile(([state, [brick, key]]) => !state.game[1].some(c => c === brck)),
    finalize(renderGameOver)
  );
const game$=combinelatetest(state$,player$)
.烟斗(
扫描(
([状态,[brick,key]])=>(
手动按键(状态、砖块、键),
砖=旋转(状态、砖、关键点),
砖=碰撞(状态,砖),
分数(状态),
重置键(键),
[说明,[砖块,钥匙]]
)),
轻触(([state[brick,key]])=>render(state,brick)),
takeWhile(([state[brick,key]])=>!state.game[1]。一些(c=>c==brck)),
最终确定(renderGameOver)
);
我只是不明白为什么扫描的功能体中有这么多ComA。这里有两个
noop,
。在我的另一个例子中,每一行都有一个逗号

另外,我不明白为什么我们要在这里将[key,letters]作为数组传递。 (说明[钥匙,字母])


我已经看完了以前提出的扫描问题,但没有一个是关于这个逗号的。

这只是javascript语法/功能的奇特/巧妙/过于复杂的用法。首先,所有这些comas:有一个逗号运算符,它计算每个操作数(从左到右)并返回最后一个操作数的值。(文件:)

简单的例子:

c = (
 a = 1, // assigns value 1 to variable a
 b = 2, // assigns value 2 to variable b
 console.log(a, b), // log values to console
 "c"
)
将输出:

1 2 // console log
"c" // value of last operand 
…和
c
变量将具有
“c”
值:

console.log(c) // prints "c"
另一个是另一个js功能-


因此,基本上所有这些都与RxJS无关,也与函数式反应式编程无关。在我看来,这样的例子过于复杂,给RxJS新手带来了不必要的噪音。

这只是javascript语法/功能的奇特/巧妙/过于复杂的使用。首先,所有这些comas:有一个逗号运算符,它计算每个操作数(从左到右)并返回最后一个操作数的值。(文件:)

简单的例子:

c = (
 a = 1, // assigns value 1 to variable a
 b = 2, // assigns value 2 to variable b
 console.log(a, b), // log values to console
 "c"
)
将输出:

1 2 // console log
"c" // value of last operand 
…和
c
变量将具有
“c”
值:

console.log(c) // prints "c"
另一个是另一个js功能-


因此,基本上所有这些都与RxJS无关,也与函数式反应式编程无关。在我看来,这些例子过于复杂,给RxJS新手带来了不必要的噪音。

@JSLover你说得对,对不起。我的例子中漏了一行。已编辑并已修复。请逐行解释此处发生的情况。分数>0和状态。分数%levelChangeThreshold==0?((letters.ltrs=[]),(state.level=state.level+1),(state.score=state.score+1),intervalSubject.next(letters.intrvl-speedAdjust))分配它们,然后返回值。或者发生了什么@remek-ambroziak@JSLover你说得对,对不起。我的例子中漏了一行。已编辑并已修复。请逐行解释此处发生的情况。分数>0和状态。分数%levelChangeThreshold==0?((letters.ltrs=[]),(state.level=state.level+1),(state.score=state.score+1),intervalSubject.next(letters.intrvl-speedAdjust))分配它们,然后返回值。或者在remek ambroziak发生了什么