Skip to content
This repository was archived by the owner on Apr 20, 2018. It is now read-only.
This repository was archived by the owner on Apr 20, 2018. It is now read-only.

Rx.Observable.spawn #936

@unao

Description

@unao

It is really nice to see spawn in the rxjs - unfortunately it seems that error handling does not work.

rx.js 4.0.0
var s = Rx.Observable.spawn(function *(){

    try {
        var err1 = yield Rx.Observable.throw('1');
        console.log('ERR_1', err1);
        var err2 = yield Promise.reject('2');
        console.log('ERR_2', err2);
    }
    catch(ex){
        // never called
        console.error('ERROR_RX_JS', ex);
    }

});

s.subscribe(
    _=>_,
    (err)=>console.log(err),
    ()=>console.log('completed')
);

Output:

ERR_1 1
ERR_2 2
completed

For comparison:

co 4.6.0
co(function *(){
    try {
        var err1 = yield Rx.Observable.throw('1')
            .toPromise();
        console.log('ERR_1', err1);
        var err2 = yield Promise.reject('2');
        console.log('ERR_2', err2);
    }
    catch(ex){
       // here `err1` is undefined
        console.error('ERROR_CO', ex);
    }
});

Output:

ERROR_CO 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions