假设我希望 Stream 在某些情况下发出错误:
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)