title: Array variable outside subscription is empty
body: <p>My goal is to read a csv file into an array in an Angular app in TypeScript.</p>
  <p>I created a function which subscribes to another function which returns an observable and puts its value in a variable.</p>
  <pre><code>  processesData: any[] = new Array();
  
    loadCvs(files: FileList) {
      const file: File = files[0];
      if(files &amp;&amp; files.length &gt; 0) {
        this.getCsv(file).subscribe((output: any[]) =&gt; {
          this.processesData = output.slice();
          console.log(this.processesData);
        });
        console.log(this.processesData);
      }
    }
  
    getCsv(file: File): Observable&lt;any[]&gt; {
      const sub = new Subject&lt;any[]&gt;();
      //File reader method
      let reader: FileReader = new FileReader();
  
      let tmp: any[] = new Array();
      reader.onload = () =&gt; {
        let csv: any = reader.result;
        let allTextLines = [];
        allTextLines = csv.split(/\r|\n|\r/);
  
        const header = allTextLines[0];
        const numberOfCols = header.split(',').length;
  
        for(let i = 0; i &lt; allTextLines.length; i++) {
          let line = allTextLines[i];
          let lineData = line.split(',');
  
          if (lineData.length &gt; numberOfCols) {
            let temp = lineData.slice(1,3).join(',');
            lineData[1] = temp;
            lineData.splice(2, 1);
          }
          tmp.push(lineData); 
        }
        sub.next(tmp.slice());
      }
      reader.readAsText(file);
  
      this.initDrawFlow(this.drawFlowHtmlElement);
      return sub.asObservable();
    }
  </code></pre>
  <p>When I log this.processData inside the subscription everything seems to work fine.
  However, when I log it outside the variable is empty.</p>