Let's say I would like the Stream to emit an error in certain cases:
import xs from 'xstream'
//...
function transformBlah(blah) {
if (blah.status >= 200 && blah.status < 300) {
return blah.body
} else {
return new Error('I would like to send an error onto the Stream here')
}
}
const blahTransformed$ = xs.create(new BlahProducer())
.map(transformBlah)
I have found that raising an exception achieves this in both
rxjs
andxstream
:The exception is caught by the Observable library, and an error is emitted on the Stream.