title: How to generate data only when there are observers?
body: <p>I'm refactoring a service in such way, that it will use RX for providing data. However, generating data is costly and I'd like to provide the data only when there are any subscribers. In general, I need the following:</p>
  <ul>
  <li>Observable should provide data to observers, when it is ready</li>
  <li>Base data will be generated asynchronously, data to be broadcasted will be generated <em>from</em> the base data</li>
  <li>Every new subscriber should receive lastly generated data (one object)</li>
  <li>Result data should be generated only when there's at least one subscriber. In particular, it should be generated when first subscriber subscribes.</li>
  </ul>
  <p>How can I solve this problem in C#? <code>BehaviorSubject&lt;T&gt;</code> seems to match most of my requirements except generating data only when needed.</p>