title: Angular 6 how to pipe http call
body: <p>I have a HTTP service, which uses HttpClient to make API calls:</p>
  
  <pre><code>//provider.service.ts
  export interface Lesson {
      id?: number,
      name: string,
      type: LessonType,
      teacher_data: string,
      student_data: string
  }
  
  export class ProviderService {
      constructor(private http: HttpClient) {}
  
      postLesson(form): Observable&lt;Lesson&gt; {        
          const body = this.getFormUrlEncoded(form.value);
          return this.http.post&lt;Lesson&gt;('/api/lesson/', body, this.postHttpOptions);
      }
  }
  </code></pre>
  
  <p>And I have a component that uses this ProviderService, like this:</p>
  
  <pre><code>onSubmit():void {
      this.providerService.createLesson(lessonForm).subscribe(result=&gt; {
          console.log(result);
          //do my stuff
        });
      }
    }
  </code></pre>
  
  <p>It works fine, everything is good. Now I want to make a LessonService, to make all http calls go through that service. It is going to cache results, emit on changes, etc.</p>
  
  <p>I wrote it in this way:</p>
  
  <pre><code>//updated lessons.component.ts
      onSubmit():void {
          this.LessonsService.createLesson(this.lessonForm).subscribe(result=&gt; {
              console.log(result);
              //do my stuff
          });
      }
  
  //lessons.service.ts
  export class LessonsService {
      constructor(private http: ProviderService) {}
  
      @Output() lessonChange: EventEmitter&lt;Lesson&gt; = new EventEmitter();
  
      public createLesson(form): Observable&lt;Lesson&gt; {
          let observable = this.http.postLesson(form);
          observable.pipe(
              map(result =&gt; {
                  //this code is not executed, I do not understand why                
                  this.lessonChange.emit(result);
                  return result;
              })
          );    
          return observable;
    }
  }
  </code></pre>
  
  <p>I want to emit an event when I get the result from my HTTP provider. What I am doing wrong?</p>