title: How to check Observable<Boolean>?
body: <p>Unfortunately, I can't understand how to check Observable.</p>
  
  <p>Depending on connection - I want to get my data from network or DB.</p>
  
  <p>I have a method that checks network connection:</p>
  
  <pre><code>companion object {
          fun isConnected() : Observable&lt;Boolean&gt; {
              val connectivityManager = MyApplication.applicationContext().getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager
              val activeNetwork = connectivityManager.activeNetworkInfo
              val isConnectedException = activeNetwork != null &amp;&amp; activeNetwork.isConnectedOrConnecting
              return Observable.just(isConnectedException)
          }
      }
  </code></pre>
  
  <p>So if it's true I want to call my network method:</p>
  
  <pre><code>override fun searchGroups(q: String): Observable&lt;List&lt;Group&gt;&gt; {
          return groupApi.searchGroups(GroupSearchRequest(q).toMap())
                  .flatMap { groupResponse -&gt; Observable.just(groupResponse.response.items) }
                  .doOnNext{ groupList -&gt; groupRepository.insertGroups(groupList)}
      }
  </code></pre>
  
  <p>and in the other case I want to call DB method:</p>
  
  <pre><code>override fun getGroupsFromDB(q: String): Observable&lt;List&lt;Group&gt;&gt; {
          return groupRepository.findByName(q)
      }
  </code></pre>
  
  <p>Here is my try to do this, but I think there is problem because of nullable interactor, but still don't know what to do.</p>
  
  <pre><code>compositeDisposable.add(
                  NetworkManager.isConnected()
                          .flatMap {
                               if (it) {
                                  interactor?.searchGroups(q)
                              } else {
                                  interactor?.getGroupsFromDB(q)
                              }
                          }
      }
      )
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xpHpD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xpHpD.png" alt="enter image description here"></a></p>
  
  <p>Could anybody please help me with that ?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>So the problem was in nullable object <code>interactor</code>.</p>
  
  <p>Could anybody please suggest the better way to not using <code>!!</code> for <code>interactor</code> object?</p>
  
  <p><a href="https://i.stack.imgur.com/n6mC6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/n6mC6.png" alt="enter image description here"></a></p>