title: How do I memoize the value emitted by a Single?
body: <p>Say I have an expensive calculation that creates an object. I want to give the caller some flexibility as to where that happens, with <code>subscribeOn()</code>. But I also don't want to make that calculation more than once, because of side effects (e.g. the object is backed by some external data store).</p>
  
  <p>I can write</p>
  
  <pre><code>MyObject myObject = MyObject.createExpensively(params);
  return Single.just(myObject);
  </code></pre>
  
  <p>but this does the expensive work on the calling thread.</p>
  
  <p>I can write</p>
  
  <pre><code>Callable&lt;MyObject&gt; callable = () -&gt; MyObject.createExpensively(params);
  return Single.fromCallable(callable);
  </code></pre>
  
  <p>but this will invoke <code>createExpensively()</code> (with side effects) once <em>per subscription</em>, which isn't what I want if there are multiple subscribers. </p>
  
  <p>If I want to ensure that <code>createExpensively()</code> is only called once, and its side effects only occur once, what's the pattern I'm looking for here?</p>