Rxjs测试 - 这可能使用大理石图也RxJs 4?

Rxjs测试 - 这可能使用大理石图也RxJs 4?

问题描述:

我有一个简单的问题。 RxJS V5使用大理石示了用于其的检测(例如here)。是否有可能在RxJS v4中使用相同的技术,如果是这样,如何?Rxjs测试 - 这可能使用大理石图也RxJs 4?

+1

开箱没有。你有没有看看[RxJS5 TestScheduler(https://github.com/ReactiveX/RxJS/blob/master/src/testing/TestScheduler.ts)?看起来像在RxJS 4中实现会相对简单。 – paulpdaniels

+0

感谢Paul,我会看看。 – user3743222

你总是可以滚你自己:这里有一个简单的函数将字符串转换为可观察到的冷发射字符串值:

// string -> Observable<string> 
function fromMarble(s) { 
    const items = s.split('-') 
     .filter(x => x); 

    return Rx.Observable.from(items); 
} 

fromMarble('--1--2--cheese--4--5').subscribe(x => console.log(x)); 
// >> 1 
// >> 2 
// >> cheese 
// >> 4 
// >> 5