title: Flow not emitting items
body: <p>The code below implements a simple screen that shows a list of users using the MVI pattern with kotlin coroutines. The code runs but does not produce any results. After alot debugging, i found out that the <strong>getUsers</strong> function in the <strong>UserListVM</strong> does not emit anything. Would appreciate some help here. thanks alot.</p>
  
  <pre><code>    class UserListVM : ViewModel() {
  
      val resultFlows: Channel&lt;Flow&lt;*&gt;&gt; = Channel(Channel.UNLIMITED)
      val liveState = MutableLiveData&lt;PModel&lt;*, UserListIntents&gt;&gt;()
      val intents: Channel&lt;UserListIntents&gt; = Channel()
  
      lateinit var job: Job
      lateinit var currentState: UserListState
  
      fun offer(event: UserListIntents) = intents.offer(event)
  
      suspend fun store(initialState: UserListState): LiveData&lt;PModel&lt;*, UserListIntents&gt;&gt; {
          job = viewModelScope.launch {
              currentState = initialState
              intents.consumeEach { intent -&gt;
                  resultFlows.send(reduceIntentsToResults(intent, currentState)
                          .flowOn(Executors.newFixedThreadPool(4).asCoroutineDispatcher())
                          .map { SuccessResult(it, intent) }
                          .catch { ErrorEffectResult(it, intent) }
                          .onStart { emit(LoadingEffectResult(intent)) }
                          .distinctUntilChanged()
                  )
              }
              resultFlows.consumeEach { results -&gt;
                  results.flatMapMerge {
                      val states = stateStream(this as Flow&lt;Result&lt;UserListResult, UserListIntents&gt;&gt;, currentState)
                      val effects = effectStream(this as Flow&lt;Result&lt;UserListEffect, UserListIntents&gt;&gt;)
                      flowOf(states, effects)
                  }
                          .flattenMerge()
                          .collect { pModel -&gt; liveState.value = pModel }
              }
          }
          job.start()
          return liveState
      }
  
      private suspend fun reduceIntentsToResults(intent: UserListIntents, currentState: Any): Flow&lt;*&gt; {
          Log.d("UserListVM", "currentStateBundle: $currentState")
          return when (intent) {
              is GetPaginatedUsersIntent -&gt; when (currentState) {
                  is EmptyState, is GetState -&gt; getUsers()
                  else -&gt; throwIllegalStateException(intent)
              }
              is UserClickedIntent -&gt; when (currentState) {
                  is GetState -&gt; flowOf((SuccessEffectResult(NavigateTo(intent.user), intent)))
                  else -&gt; throwIllegalStateException(intent)
              }
          }
      }
  
      private suspend fun getUsers(): Flow&lt;UsersResult&gt; {
          return flow {
              emit(UsersResult(listOf(User("user1", 1), User("user2", 2), User("user3", 3))))
          }.flowOn(Dispatchers.IO)
      }
  
      override fun onCleared() {
          super.onCleared()
          job.cancel()
      }
      }
  
      class UserListActivity : AppCompatActivity() {
  
      var intentStream: Flow&lt;UserListIntents&gt; = flowOf()
      lateinit var viewModel: UserListVM
      lateinit var viewState: UserListState
      private lateinit var usersAdapter: GenericRecyclerViewAdapter
  
      override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          initialize()
          setupUI(savedInstanceState == null)
          viewModel.store(viewState).observe(this, Observer {
              it?.apply {
                  when (this) {
                      is ErrorEffect -&gt; bindError(errorMessage, error, intent)
                      is SuccessEffect -&gt; bindEffect(bundle as UserListEffect)
                      is SuccessState -&gt; {
                          (bundle as UserListState).also { state -&gt;
                              viewState = state
                              bindState(state)
                          }
                      }
                  }
                  toggleLoadingViews(intent)
              }
          })
      }
  
      fun initialize() {
          viewModel = getViewModel()
          viewState = EmptyState()
      }
  
      fun setupUI(isNew: Boolean) {
          setContentView(R.layout.activity_user_list)
          setSupportActionBar(toolbar)
          toolbar.title = title
          setupRecyclerView()
      }
  
      override fun onResume() {
          super.onResume()
          if (viewState is EmptyState) {
              GlobalScope.launch {
                  viewModel.offer(GetPaginatedUsersIntent(0))
              }
          }
      }
  
      private fun bindState(successState: UserListState) {
          usersAdapter.setDataList(successState.list, successState.callback)
      }
  
      private fun bindEffect(effectBundle: UserListEffect) {
          when (effectBundle) {
              is NavigateTo -&gt; {
                 // ..
              }
          }
      }
  
      fun bindError(errorMessage: String, cause: Throwable, intent: UserListIntents) {
          //..
      }
  
      private fun setupRecyclerView() {
          usersAdapter = object : GenericRecyclerViewAdapter() {
              override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GenericViewHolder&lt;*&gt; {
                  return when (viewType) {
                      R.layout.empty_view -&gt; EmptyViewHolder(layoutInflater
                              .inflate(R.layout.empty_view, parent, false))
                      R.layout.user_item_layout -&gt; UserViewHolder(layoutInflater
                              .inflate(R.layout.user_item_layout, parent, false))
                      else -&gt; throw IllegalArgumentException("Could not find view of type $viewType")
                  }
              }
          }
          usersAdapter.setAreItemsClickable(true)
          user_list.layoutManager = androidx.recyclerview.widget.LinearLayoutManager(this)
          user_list.adapter = usersAdapter
          usersAdapter.setAllowSelection(true)
          intentStream = flowOf(intentStream, user_list.scrollEvents()
                  .map { recyclerViewScrollEvent -&gt;
                      GetPaginatedUsersIntent(
                              if (ScrollEventCalculator.isAtScrollEnd(recyclerViewScrollEvent))
                                  viewState.lastId
                              else -1)
                  }
                  .filter { it.lastId != -1L }
                  .conflate()
                  .onEach { Log.d("NextPageIntent", "fired!") })
                  .flattenMerge()
      }
  
      fun toggleLoadingViews(isLoading: Boolean, intent: UserListIntents?) {
          linear_layout_loader.bringToFront()
          linear_layout_loader.visibility = if (isLoading) View.VISIBLE else View.GONE
      }
      }
  </code></pre>