title: rxjs equivalent of stopping an async function using 'return';
body: <p>I want to implement something similar below(they are easy if using promises)</p>
  
  <pre><code>async doSomething(sID){
   let student = await service.getStudent(sID);
   let teacher = await service.getTeacher(student.TeacherID);
   if(!teacher.Active){
     return;
   }
  
   await service.teacherSomething(teacher);
   await service.studentSomething(student);
  }
  </code></pre>
  
  <p>I have no clue on how to do this if I am using observables instead of promises but this is the one I tried so far</p>
  
  <pre><code>doSomething(sID){
    let student;
    let teacher;
    service.getStudent(sID).pipe(
        switchMap(studentR=&gt;{
          student = studentR;
          return service.getTeacher(student.TeacherID);
        }),
        switchMap(teacherR=&gt;{
          teacher = teacherR;
          if(!teacher.Active){
              return of(null);
          }else{
              return service.teacherSomething(teacher);
          }
        }),
        swicthMap(teacherSomethingResponse=&gt;{
            if(teacherSomethingResponse==null){
                return of(null);
            }else{
              return service.studentSomething(student);
            }
        })
    }).subscribe();
  
  }
  </code></pre>
  
  <p>as you can see, my rxjs version seems TOO LONG compared to the promise version and I feel like i am not doing it the right way.</p>