2016-08-18 1 views
0

ストリームに結合してh1にテキストを表示するのがうまくいっていません。なぜ私はcyclejsでxstreamを使ってストリームを結合できないのですか?

しかし、それを動作させることができない:

これは私のコードです:

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) 

遠い

+0

ファイル* index.js *の行6とは何ですか? – bloodyKnuckles

+0

'combine'部分はここでうまくいきます:http://www.webpackbin.com/VkmIaiCtZ – bloodyKnuckles

+0

ありがとうございました。結合されたストリームがvtreeに行くときに問題が起きているようです。 webpackbinは非常にお勧めです。ここに追加コードがあります: [http://www.webpackbin.com/VkpnY30K-](http://www.webpackbin.com/VkpnY30K-) – ismapro

答えて

2

私の問題は、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の皆さん。

関連する問題