title: rxjs - understand observable and observer
body: <p>I can't get my head around observable and observer (rxjs), i understand that observable can dispatch the messages to observer, and observer subscribe to observable, but I dont know how to setup this?</p>
  
  <p>Lets say I would like to request URL, first time the user call "loadData", the data is loaded from http request, and saved locally inside the class, next time the user call "loadData", we dont want to load from http, but get the data locally, but I would like to use the same code "loadData", and it should return Observer, so the developed don't know where and how the data is loaded!</p>
  
  <pre><code>let data = [];
  function loadData():Observer {
     var observer = new Observer();
     if (data.length &gt; 0) {
        var observable = new Observable.from(data);
        observable.add(observer);
        observable.notify();
     } else {
        var observable = this.http.get("data.json");
        observable.add(observer);
        observable.readyData( (data) =&gt; { 
           this.data = data; 
           observable.notify(); 
        };
    }
  }
  
  var observer = loadData();
  observer.dataComing((data) =&gt; console.log(data));
  </code></pre>
  
  <p>Any explanation or link to any page would be great, I understand map filter reduce in Array etc, and also the observer pattern which is easy, but not RXJS way, it's very confusing! </p>
  
  <p>Thank you very much!</p>