2016-08-18 7 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의 모든 사람.