RxJS: Splitting an array result from Observable.fromPromise

后端 未结 1 550
逝去的感伤
逝去的感伤 2021-01-17 15:51

I\'m using RxJS here and I can\'t seem to get over this seemingly simple issue.

rx.Observable
    .from([1,2,3,54,3,22,323,23,11,2])
    .distinct()         


        
相关标签:
1条回答
  • 2021-01-17 16:35

    No it will not break them apart implicitly. If you want to split them use flatMap which will flatten the array:

     rx.Observable
        .fromPromise(getNumbers([1,2,3,54,3,22,323,23,11,2]))
        .flatMap(function(x) { return x; })
        .distinct()
        .subscribe(function next (x) {
            console.log('Next');
            console.log(x);
        }, function error (x) {
            console.log('Error');
            console.log(x);
        }, function completed () {
            console.log('Completed');
        });
    
    0 讨论(0)
提交回复
热议问题