Ionic2 or Angular2 http request on interval
<p>I am trying to create a data service that pulls data from my API every set number of seconds and returns two Observables of the two different data types that the API returns. I am new to Observables so any help would be greatly appreciated.</p>

<p>My API returns a two arrays of json objects (ex <code>{'Data1':[array of data objects], 'Data2':[array of data objects]}</code>). Can I do something similar to this?</p>

<pre><code>@Injectable()
export class DataService {
  data: any = null;
  dataType1: DataType1Model[] = [];
  dataType2: DataType2Model[] = [];
  service: Observable;

  constructor(public http: Http) {}

  start() {
    this.service = Observable.interval(10000)
      .flatMap(() =&gt; {
        this.http.get('url')
            .map(res =&gt; res.json())
            .subscribe(data =&gt; {
              this.data = data;
              this.processData1(this.data.Data1);
              this.processData2(this.data.Data2);
            });
        })
      .subscribe()
  }

  stop(){
    this.service.unsubscribe()
  }

  getData1() {
    return this.dataType1
  }

  getData2() {
    return this.dataType2
  }
}
</code></pre>

<p>Then in my component I can just import the DataService and call <code>data1 = DataService.getData1()</code>?</p>

<p>Will that call be an observable that will continue to update the data on the 10sec interval when the http request triggers? Again, I am new to observables, so sorry if this is totally wrong.</p>