<commit_before>import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';

@Injectable()
export class LoaderService {
  constructor(protected http: Http) {}
  get(url:string): Observable<string[]> {
    return this.http.get(url)
      .map((res: Response) => res.json())
      .catch(this.handleError);
  }

  private handleError (error: any) {
    let errMsg:string = (error.message) ? error.message :
      error.status ? `${error.status} - ${error.statusText}` : 'Server error';
    return Observable.throw(errMsg);
  }
}<commit_msg>Added a data observer which will be used to notify components once data has changed.<commit_after>import { Injectable } from '@angular/core';
import { Http, Response } from '@angular/http';
import { Observable } from 'rxjs/Observable';
import { Observer } from 'rxjs/Observer';
import 'rxjs/add/operator/map';
import 'rxjs/add/operator/catch';
import 'rxjs/add/observable/throw';

@Injectable()
export class LoaderService {
  data$:Observable<any[]>;
  private dataObserver:Observer<any[]>;

  constructor(protected http: Http) {
    this.data$ = new Observable<any[]>(
      (observer:Observer<any[]>) => this.dataObserver = observer
    );
  }

  get(url:string): Observable<string[]> {
    return this.http.get(url)
      .map((res: Response) => res.json())
      .catch(this.handleError);
  }

  changeData(data:Array<any>) {
    if(this.dataObserver) {
      this.dataObserver.next(data);
    }
  }

  private handleError (error: any) {
    let errMsg:string = (error.message) ? error.message :
      error.status ? `${error.status} - ${error.statusText}` : 'Server error';
    return Observable.throw(errMsg);
  }
}
{'fraction_non_alphanumeric': 0.15778019586507072, 'fraction_numerical': 0.0, 'mean_word_length': 4.108333333333333, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2883615', 'n_tokens_mistral': 580, 'n_tokens_neox': 577, 'n_words': 128}