0

I have a simple question. RxJS v5 uses marble diagrams for its testing (example here). Is it possible to use the same technique in RxJS v4 and if so, how to ?

user3743222
  • 18,345
  • 5
  • 69
  • 75
  • 1
    Out of the box there isn't. Have you had a look at the [RxJS5 TestScheduler](https://github.com/ReactiveX/RxJS/blob/master/src/testing/TestScheduler.ts)? Seems like it would be relatively straight forward to implement in RxJS 4. – paulpdaniels Mar 06 '16 at 09:06
  • thanks Paul, I'll have a look. – user3743222 Mar 06 '16 at 13:32

1 Answers1

2

You can always roll your own: here's a simple function to convert a string to a cold observable that emits string values:

// 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
Calvin Belden
  • 3,114
  • 1
  • 19
  • 21