title: What does the .subscribe() function do?
body: <p>I am coding an API with <code>Angular2</code> and <code>NodeJS</code>, I am implementing services for my ِAPI that is supposed to get a list of tasks and display it. Here is the task service:</p>
  
  <pre><code>import {Injectable} from '@angular/core';
  import {Http, Headers} from '@angular/http';
  import 'rxjs/add/operator/map';
  
  @Injectable()
  export class TaskService{
    constructor(private http:Http){
      console.log('Task Service Initialized...');
    }
    getTasks(){
      return this.http.get('http://localhost:3000/api/tasks')
        .map(res =&gt; res.json());
    }
  }
  </code></pre>
  
  <p>For my <code>getTask</code> function (correct me if I am wrong) the <code>.map()</code> function takes my response and formats it in an array of values.
  Here is now, the task components that uses the task service: </p>
  
  <pre><code>import { Component } from '@angular/core';
  import {TaskService} from '../../services/task.service';
  
  @Component({
    moduleId: module.id,
    selector: 'tasks',
    templateUrl: 'tasks.component.html',
  })
  export class TasksComponent  {
    constructor(private taskService:TaskService){
      this.taskService.getTasks()
        .subscribe(tasks =&gt;{
          console.log(tasks);
      })
    }
  }
  </code></pre>
  
  <p>I would like to understand what this <code>.subscribe()</code> function does and I can't find any relevant information.</p>