title: Polling repository with coroutine channels
body: <p>I'm playing with coroutine channels and I wanted to implemented a polling test project. The idea is that a viewmodel will listen for data from a repository that polls an endpoint repeatedly.</p>
  
  <p>When I pass a coroutineScope to the repository, the polling works, however when I create a new coroutineSCope in the repository, I see the data being injected into the channel, but it's not received on the viewmodel.</p>
  
  <p>So this works:</p>
  
  <pre><code>class PollingViewModel : ViewModel() {
  
      val counter = MutableLiveData&lt;String&gt;().apply { value = "uninitialized" }
  
      private val repository = Repository()
  
      init {
          viewModelScope.launch {
              val channel = repository.poll(this /* scope */)
              channel.consumeEach {
                  Log.d("foo", "Viewmodel received [$it]")
                  counter.postValue(it.toString())
              }
          }
      }
  }
  
  class Repository {
  
      private var startValue = 0
  
      suspend fun poll(coroutineScope: CoroutineScope) =
          coroutineScope.produce(capacity = Channel.CONFLATED) {
              while (true) {
                  Log.d("foo", "Sending value [$startValue]")
                  send(startValue++)
                  delay(POLLING_PERIOD_MILLIS)
              }
          }
  
      companion object {
          private const val POLLING_PERIOD_MILLIS = 1000L
      }
  }
  </code></pre>
  
  <p>But this does not (viewmodel does not receive anything):</p>
  
  <pre><code>class PollingViewModel : ViewModel() {
  
      val counter = MutableLiveData&lt;String&gt;().apply { value = "uninitialized" }
  
      private val repository = Repository()
  
      init {
          viewModelScope.launch {
              repository.poll().consumeEach {
                  Log.d("foo", "Viewmodel received [$it]")
                  counter.postValue(it.toString())
              }
          }
      }
  }
  
  class Repository {
  
      private var startValue = 0
  
      suspend fun poll() = coroutineScope {
          produce(capacity = Channel.CONFLATED) {
              while (true) {
                  Log.d("foo", "Sending value [$startValue]")
                  send(startValue++)
                  delay(POLLING_PERIOD_MILLIS)
              }
          }
      }
  
      companion object {
          private const val POLLING_PERIOD_MILLIS = 1000L
      }
  }
  </code></pre>
  
  <p>What is the issue with creating a coroutineScope at the repository level?</p>