How to make outer Observable aware from inner Observable error or success in nested Observables?

How to make outer Observable aware from inner Observable error or success in nested Observables ?

Why onNext and onCompleted is undefined inside inner Observable ?

public updateDocument(item: Document): Observable<any> {
    let afiEdit = this.offlineData.afi.edit;

    //outer observable
    return Observable.create(observer => {
        //inner observable
            (next) => {
            (err) => {                
                //how to throw error to outer observable
            () => {

        return () => console.log('cleanup message')

My understanding is that your goal is simply to throw an error in the outer observable, when the inner observable fails.

So the code will look like this:

//Define the inner observable (probably an http call in your case)
//I mocked your call failing or passing with a random 50/50 chance
var innerObservable = new Rx.Observable(observer => {
  var didMockCallFail = Math.random() < .5; 
    console.log('Inner observable call failed');
    observer.error(new Error('Call failed!'));
  } else {
    console.log('Inner observable call returned data');{lolData: 'I am data'}); 

//define the outer observable which just calls the inner observable
var outerObservable = new Rx.Observable(observer => {
    data =>,
    err => observer.error(err)

  next => console.log('Got data!'),
  err => console.error('lol fail')

Furthermore, note that if you want to pass variables to Observables and make that code re-usable / avoid global scope, you can use a generator function, e.g.

function makeObs(someParam){
  return new Rx.Observable(observer => {;

Let me know if you have any questions.



geT the cheap price in the