title: Call component method from service
body: <p>I am completly new in angular. I have 2 components, one for displaying list of taks, one for adding new one. They use one service. This is my function in TasksComponent:</p>
  
  <pre><code>getTasks(): void {
    this.tasksService.getTasks()
                         .subscribe(
                             tasks =&gt; this.tasks = tasks,
                              err =&gt; {
                                  console.log(err);
                              });
  }
  </code></pre>
  
  <p>And I have also function for adding new Task in TasksInputFormComponent. So I need to call getTasks() function from another component using shared service. I have found this question <a href="https://stackoverflow.com/questions/40788458/how-to-call-component-method-from-service-angular2">How to call component method from service? (angular2)</a> and have tried to do something like in example. I don't understand how to do it right.
  In tasksService:</p>
  
  <pre><code>private componentMethodCallSource = new Subject&lt;any&gt;();
  componentMethodCalled$ = this.componentMethodCallSource.asObservable();
  </code></pre>
  
  <p>In TasksComponent:</p>
  
  <pre><code>  constructor(private tasksService: TasksService) {
      this.tasksService.componentMethodCalled$.subscribe(
      () =&gt; {
        this.tasksService.getTasks()
                         .subscribe(
                             tasks =&gt; this.tasks = tasks,
                              err =&gt; {
                                  console.log(err);
                              });
      }
    );
  </code></pre>
  
  <p>}</p>
  
  <p>In TasksInputFormComponent:</p>
  
  <pre><code>   addTask(task) {
      ...
      this.tasksService.addTask(...);
      this.tasksService.callComponentMethod();
    }
  </code></pre>
  
  <p>But this code looks absolutly strange and doesn't work. I can't find how to do it properly.</p>