title: JS, JQuery and Observable
body: <p>I`m building third party application for specific sites with Jquery.</p>
  
  <p>Recently I started to use rx.Observable in my project. However, I found to use of this new JS library sometimes is hard to understand. I have tried to convert next peace of code to use with Observables, but it is not working at all;</p>
  
  <pre><code>class EventsUtils {
  
      constructor() {       
          this.observable = Rx.Observable;      
      }
      bindUserLeavePageEvent() {
          var self = this;
          document.addEventListener('mouseleave', (e) =&gt; {
              $JQ(document).trigger('mouseleave.mo');
          }, false);
              /*We cannot remove document mouse over event thus we trigger Jquery registered custom event and on remove we cancel it*/
          $JQ(document).off('mouseleave.mo').on('mouseleave.mo', (e) =&gt; {
              if (e.clientY &lt; 0 &amp;&amp; !self.loaded) {
                  console.log('loading from screen Leave');
                  $JQ('.fixed-button').trigger('click');
                  self.loaded = true;                
              }
          });
  }
  </code></pre>
  
  <p>$JQ variable is came from jquery.noConflict due to i am running not on my page.
    To convert second expression to Observable I have tried to use next statement:</p>
  
  <pre><code>this.observable.fromEvent(document, 'mouseleave.mo').pluck('currentTarget').subscribe(x=&gt;console.log(x));
  }
  </code></pre>
  
  <p>But without success.
  How to convert above event statements to use with Observable and what is common pattern to do this;</p>