title: Should be used a CoroutineScope's extension function or a suspending function
body: <p>I'm writing an app using coroutines (code below is greatly simplified). Recently I've watched <a href="https://youtu.be/a3agLJQ6vt8?t=2195" rel="nofollow noreferrer">Coroutines in Practice</a> talk and got a little confused. Turns out I don't know when to use a <code>CoroutineScope</code>'s extension function and when to use a suspending function.</p>
  
  <p>I have a <strong>mediator</strong> (Presenter/ViewModel/Controller/etc) that implements CoroutineScope:</p>
  
  <pre><code>class UiMediator : CoroutineScope {
      private val lifecycleJob: Job = Job()
      override val coroutineContext = lifecycleJob + CoroutineDispatchersProvider.MAIN
      // cancel parent Job somewhere
  
      fun getChannel() {
          launch {
              val channel = useCase.execute()
              view.show(channel)
          }
      }
  }
  </code></pre>
  
  <p><strong>Business logic</strong> (Interactor/UseCase):</p>
  
  <pre><code>class UseCase {
      suspend fun execute(): RssChannel = repository.getRssChannel()
  }
  </code></pre>
  
  <p>And a <strong>repository</strong>:</p>
  
  <pre><code>class Repository {
      suspend fun getRssChannel(): RssChannel {
          // `getAllChannels` is a suspending fun that uses `withContext(IO)`
          val channels = localStore.getAllChannels()
          if (channels.isNotEmpty()) {
              return channels[0]
          }
  
          // `fetchChannel` is a suspending fun that uses `suspendCancellableCoroutine`
          // `saveChannel` is a suspending fun that uses `withContext(IO)`
          return remoteStore.fetchChannel()
              .also { localStore.saveChannel(it) }
      }
  }
  </code></pre>
  
  <p>So I have a few questions:</p>
  
  <ol>
  <li>Should I declare <code>Repository#getRssChannel</code> as a CoroutineScope's extension function (because
  it spawns new suspending functions: <code>getAllChannels</code>,
  <code>fetchChannel</code>, <code>saveChannel</code>)? How can I use it in the <code>UseCase</code> then?</li>
  <li>Should I just wrap a <code>Repository#getRssChannel</code> into a
  <code>coroutineScope</code> function in order to make all spawned suspending
  functions to be children of the latter?</li>
  <li>Or maybe it's already fine and I should change nothing. When to
  declare  a function as a <code>CoroutineScope</code>'s extension then?</li>
  </ol>