为什么我不能在 cyclejs 中使用 xstream 合并流?
why I can't combine streams using xstream in cyclejs?
我正在尝试将流合并为一个流并在 h1 中显示文本,但未成功。
但无法让它工作:
这是我的代码:
function main(sources) {
// single streams
let letter$ = xs.of({text: 'abcd'});
let number$ = xs.of({text: '123456'});
//try to combine them into one
const combined$ =
xs.combine( letter$, number$ ).
map( ( [ letter, number ] ) => {
return { text: letter.text + ' ' + number.text };
});
//updates the virtual dom with the reponse
const vdom$ = combined$
.map(o => o.text)
.startWith('Loading...')
.map(text =>
div('.container', [
h1(text)
])
);
return {
DOM: vdom$
};
}
它显示错误说:
index.js:6 TypeError: f is not a function
at invoke (core.js:36)
at CombineListener._n (core.js:72)
at Stream._n (core.js:886)
at FromArrayProducer._start (core.js:142)
at Stream._add (core.js:959)
at CombineProducer._start (core.js:118)
at Stream._add (core.js:959)
at MapOperator._start (core.js:681)
at Stream._add (core.js:959)
at StartWithOperator._start (core.js:786)
正在尝试了解原因,但到目前为止还没有成功。
我的问题是使用 CycleJS 存储库中示例的 package.json 中指定的依赖项。
那些依赖项已过时:
https://github.com/cyclejs/cyclejs/blob/master/examples/http-search-github/package.json
"dependencies": {
"@cycle/xstream-run": "1.1.0",
"@cycle/dom": "10.0.0-rc20",
"@cycle/http": "9.0.0-rc3",
"xstream": "2.4.x"
}
迄今为止的依赖项是:
"@cycle/dom": "^12.1.0",
"@cycle/http": "^10.1.0",
"@cycle/xstream-run": "^3.0.4",
"xstream": "^5.3.6"
经验法则检查最新的稳定依赖项。
感谢@bloodyKnuckles,以及 CycleJS gitter 中的每个人。
我正在尝试将流合并为一个流并在 h1 中显示文本,但未成功。
但无法让它工作:
这是我的代码:
function main(sources) {
// single streams
let letter$ = xs.of({text: 'abcd'});
let number$ = xs.of({text: '123456'});
//try to combine them into one
const combined$ =
xs.combine( letter$, number$ ).
map( ( [ letter, number ] ) => {
return { text: letter.text + ' ' + number.text };
});
//updates the virtual dom with the reponse
const vdom$ = combined$
.map(o => o.text)
.startWith('Loading...')
.map(text =>
div('.container', [
h1(text)
])
);
return {
DOM: vdom$
};
}
它显示错误说:
index.js:6 TypeError: f is not a function
at invoke (core.js:36)
at CombineListener._n (core.js:72)
at Stream._n (core.js:886)
at FromArrayProducer._start (core.js:142)
at Stream._add (core.js:959)
at CombineProducer._start (core.js:118)
at Stream._add (core.js:959)
at MapOperator._start (core.js:681)
at Stream._add (core.js:959)
at StartWithOperator._start (core.js:786)
正在尝试了解原因,但到目前为止还没有成功。
我的问题是使用 CycleJS 存储库中示例的 package.json 中指定的依赖项。
那些依赖项已过时:
https://github.com/cyclejs/cyclejs/blob/master/examples/http-search-github/package.json
"dependencies": {
"@cycle/xstream-run": "1.1.0",
"@cycle/dom": "10.0.0-rc20",
"@cycle/http": "9.0.0-rc3",
"xstream": "2.4.x"
}
迄今为止的依赖项是:
"@cycle/dom": "^12.1.0",
"@cycle/http": "^10.1.0",
"@cycle/xstream-run": "^3.0.4",
"xstream": "^5.3.6"
经验法则检查最新的稳定依赖项。
感谢@bloodyKnuckles,以及 CycleJS gitter 中的每个人。