What is the difference between Observer.Throw and Observer.Error in TypeScript – Observable?

What is the difference between observer.throw (error) and observer.error (error)?

I am using RxJS version “5.0.0-beta.12”

var innerObservable = new Observable(observer => {
console.log('Inner observable call failed');
observer.error(new Error('Call failed!'));
})


var outerObservable = new Observable(observer => {
innerObservable.subscribe(
data => {
observer.next(data);
observer.onCompleted();
},
err => {
//observer.throw(err); // `console.error` doesn't get called
observer.error(err); // // `console.error` it's called
}
)
});

outerObservable.subscribe(
next => {
console.log('ok!');
}
, err => {
console.error('error');
}
, () = > {
console.log('done');
}
);

Actually your observer is Subscriber class. It has an error() method, but no throw() method.
There is Observable.throw(), but that's a different thing.

> observer. throw(error) does not exist.> Observable.throw(err) is an observable that only sends out an error notification.> observer.error() is usually used in Observable.create() callbacks to send errors to newly subscribed observers Notification (like .next() or .complete).

What is the difference between observer.throw (error) and observer.error (error)?

I am using RxJS version "5.0.0-beta.12"

var innerObservable = new Observable(observer => {
console.log('Inner observable call failed');
observer.error(new Error('Call failed!'));
})


var outerObservable = new Observable(observer => {
innerObservable.subscribe(
data => {
observer.next(data);
observer.onCompleted();
},
err => {
//observer.throw(err); // `console.error` doesn't get called
observer.error(err); // // `console.error` it's called
}
)
});

outerObservable.subscribe(
next => {
console.log('ok!');
}
, err => {
console.error('error');
}
, () = > {
console.log('done');
}
);

Actually your observer It is an instance of Subscriber class. It has an error() method, but no throw() method.
There is Observable.thr ow(), but that is a different thing.

> observer.throw(error) does not exist.> Observable.throw(err) is an observable that only sends out an error notification.> observer .error() is usually used in the Observable.create() callback to send error notifications to newly subscribed observers (just like .next() or .complete).

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4421 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.