title: how to pass object to rxjs subscribe() callback function?
body: <p>I am developing a Ionic2 App, using the cordova-plugin-network-information, I am subscribing to the connect and disconnect events from my app.ts and want to be able to pass a reference to my NavController and a Loading component into the subscribe() callback, so whenever the event for a disconnect fires, I can present the user with a Loading overlay on top of the UI. I see that in the callback the reference to the "this" object changes to an object called "SafeSubscriber", which I think is the rxjs typed class for its Observer object, the problem I have here is that I have no way to get those instances available in app.ts to this code inside the callback, using the Chrome DevTools I also wasn't able to find my way out of this context in order to access the App object itself. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>    ngOnInit()
      {
        // Nav Controller:
        this.nav = &lt;NavController&gt;this.app.getComponent('nav');
  
        // Disconnect Detection
        let disconnectSubscription = Network.onDisconnect().subscribe(() =&gt;
        {
            console.log('Disconnect Detected');
            // Push Loading into nav stack here...!
            // this.nav.present(this.loading);  &lt;- no this object...
        });
      }
  </code></pre>
  
  <p>This is what I get when querying for the 'this' object inside Chrome DevTools (this is supposed to keep its original context inside a lambda [fat arrow] function is this correct?) </p>
  
  <p><a href="https://i.stack.imgur.com/SHAUY.png" rel="noreferrer"><img src="https://i.stack.imgur.com/SHAUY.png" alt="enter image description here"></a></p>
  
  <p>I have tried setting a "that" object before doing the subscription, so that the variable "this" doesn't interfere with the callback "this" scope, it didn't work in this scenario, as 'that' which was declared immediately before the subscribe() (let that: any = this;) was undefined inside of the callback when the disconnect event was fired. </p>
  
  <p>I know that this is not the best place to put code that changes directly the UI, but I see no other place, since what I need here is a global event handler that works by setting this overlay whenever there is no connection detected and the user is viewing certain pages within the app. </p>
  
  <p>I think there should be a very easy and elegant solution to this, but I don't seem to be able to find it. Is there a way to pass a parameter to the subscribe() function? some sort of object with the references I need?</p>
  
  <p>Thanks in advance.</p>