Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/439.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 Rx.Observable.merge不工作_Javascript_Rxjs_Observable - Fatal编程技术网

Javascript Rx.Observable.merge不工作

Javascript Rx.Observable.merge不工作,javascript,rxjs,observable,Javascript,Rxjs,Observable,我正在尝试使用Rxjs构建一个示例秒表应用程序。但当我尝试合并暂停和重置流时,它不起作用。 这是我的密码 //我们需要什么 /* 1.区间观测器 2.单击3个按钮中的流 */ const startButton=document.querySelector(“开始”) const stopButton=document.querySelector(“停止”) const resetButton=document.querySelector(“重置”) const start$=Rx.Obser

我正在尝试使用Rxjs构建一个示例秒表应用程序。但当我尝试合并暂停和重置流时,它不起作用。 这是我的密码

//我们需要什么
/*
1.区间观测器
2.单击3个按钮中的流
*/
const startButton=document.querySelector(“开始”)
const stopButton=document.querySelector(“停止”)
const resetButton=document.querySelector(“重置”)
const start$=Rx.Observable.fromEvent(开始按钮“单击”)
const stop$=Rx.Observable.fromEvent(停止按钮,'单击')
const reset$=Rx.Observable.fromEvent(重置按钮“单击”)
常数间隔$=Rx.可观测间隔(1000)
const stopOrReset$=Rx.Observable.merge(
停止$,
重置$
)
常量可暂停$=间隔$
.takeUntil(stopOrReset$)
常量init=0
常数inc=acc=>acc+1
常数重置=acc=>init
const incOrReset$=Rx.Observable.merge(
pausible.mapTo(公司),
重置$.mapTo(重置)
)
应用程序$=开始$
.switchMapTo(不相关$)
.startWith(init)
.scan((acc,currFunc)=>currFunc(acc))
.subscribe(val=>console.log(val))
正文{
背景:#ffa600;
字体系列:“HelveticaNeue Light”,“Helvetica Neue”,Helvetica,Arial,“Lucida Grande”,无衬线;
身高:100%;
}
.包装纸{
wdith:800px;
保证金:50px自动;
颜色:#fff;
文本对齐:居中;
}
#钟{
保证金:5美元;
字号:4em;
}
钮扣{
边界半径:5px;
背景:#fffa600;
颜色:#fff;
边框:实心1px#fff;
文字装饰:无;
光标:指针;
字体大小:1.2米;
填充:18px 10px;
宽度:180px;
利润率:10px;
大纲:无;
}
按钮:悬停{
过渡:所有0.5s缓进缓出;
背景:#fff;
边框:实心1px#fff;
颜色:#ffa600;
}

JS-Bin
开始
停止
:
:
重置
对于
const resetButton=document.querySelector(“reset”)

这就是问题所在

const startButton=document.querySelector(“开始”)
const stopButton=document.querySelector(“停止”)
const resetButton=document.querySelector(“重置”)
const start$=Rx.Observable.fromEvent(开始按钮“单击”)
const stop$=Rx.Observable.fromEvent(停止按钮,'单击')
const reset$=Rx.Observable.fromEvent(重置按钮“单击”)
常数间隔$=Rx.可观测间隔(1000)
常量可暂停$=间隔$
.takeUntil(停止$)
常量init=0
常数inc=acc=>acc+1
常数重置=acc=>init
const incOrReset$=Rx.Observable.merge(
pausible.mapTo(公司),
重置$.mapTo(重置)
)
应用程序$=开始$
.switchMapTo(不相关$)
.startWith(init)
.scan((acc,currFunc)=>currFunc(acc))
.subscribe(val=>console.log(val))
正文{
背景:#ffa600;
字体系列:“HelveticaNeue Light”,“Helvetica Neue”,Helvetica,Arial,“Lucida Grande”,无衬线;
身高:100%;
}
.包装纸{
wdith:800px;
保证金:50px自动;
颜色:#fff;
文本对齐:居中;
}
#钟{
保证金:5美元;
字号:4em;
}
钮扣{
边界半径:5px;
背景:#fffa600;
颜色:#fff;
边框:实心1px#fff;
文字装饰:无;
光标:指针;
字体大小:1.2米;
填充:18px 10px;
宽度:180px;
利润率:10px;
大纲:无;
}
按钮:悬停{
过渡:所有0.5s缓进缓出;
背景:#fff;
边框:实心1px#fff;
颜色:#ffa600;
}

JS-Bin
开始
停止
:
:
重置