title: How can I leverage reactive extensions to do caching, without a subject?
body: <p>I want to be able to fetch data from an external Api for a specific request, but when that data is returned, also make it available in the cache, to represent the current state of the application.</p>
  
  <p>This solution seems to work:</p>
  
  <pre><code>var Rx = require('rx');
  
  var cached_todos = new Rx.ReplaySubject(1);
  
  var api = {
    refresh_and_get_todos: function() {
      var fetch_todos = Rx.Observable.fromCallback($.get('example.com/todos'));
      return fetch_todos()
        .tap(todos =&gt; cached_todos.onNext(todos));
    },
    current_todos: function() {
      return cached_todos;
    }
  };
  </code></pre>
  
  <p>But - apparently <code>Subjects</code> are bad practice in Rx, since they don't really follow functional reactive programming.</p>
  
  <p>What is the right way to do this in a functional reactive programming way?</p>