title: Subscribe and immediately unsubscribe after first action
body: <p>I want to subscribe on an <code>IObservable&lt;T&gt;</code> and unsubscribe (dipose) the subscription right after receiving the first element of type <code>T</code>, i.e. I only want to call the action on the very first element I get after subscribing.</p>
  
  <p>This is the approach I came up with:</p>
  
  <pre><code>public static class Extensions
  {
      public static void SubscribeOnce&lt;T&gt;(this IObservable&lt;T&gt; observable, Action&lt;T&gt; action)
      {
          IDisposable subscription = null;
          subscription = observable.Subscribe(t =&gt;
          {
              action(t);
              subscription.Dispose();
          });
      }
  }
  </code></pre>
  
  <p>Example usage:</p>
  
  <pre><code>public class Program
  {
      public static void Main()
      {
          var subject = new Subject&lt;int&gt;();
  
          subject.OnNext(0);
          subject.OnNext(1);
          subject.SubscribeOnce(i =&gt; Console.WriteLine(i));
          subject.OnNext(2);
          subject.OnNext(3);
  
          Console.ReadLine();
      }
  }
  </code></pre>
  
  <p>It works as expected and only prints <code>2</code>. <strong>Is there anything wrong with this or anything else to consider? Is there a cleaner way using the extension methos that come with RX out of the box maybe?</strong></p>