title: When should i collect SharedFlow events in Fragment lifecycle
body: <p>I have thought that is okay to collect SharedFlow data on onViewCreated. But when i replace fragment n times then fire some event to SharedFlow, it emits n times event to me instead of one event.</p>
  <p>I have fixed it how i put my code on onCreate at my Fragment. But i haven't found any documentation about that. Am i missing something or i should keep using SharedFlow collections at onCreate in Fragment ?</p>
  <pre><code>    override fun onCreate(savedInstanceState: Bundle?) {
      super.onCreate(savedInstanceState)
      lifecycleScope.launchWhenResumed {
          viewModel.uiEffect.collect {
              when (it) {
                  is ViewEffectWrapper.PageEffect -&gt; {
                      if (it.pageEvent is LoginViewEffect.OpenHomePage) {
                          startActivity(
                              Intent(
                                  this@LoginFragment.context,
                                  HomeActivity::class.java
                              )
                          )
                      }
                  }
  
              }
          }
      }
  }
  </code></pre>
  <p>And here is my SharedFlow definition at ViewModel</p>
  <pre><code>private val _uiEffect = MutableSharedFlow&lt;ViewEffectWrapper&lt;LoginViewEffect&gt;&gt;(replay = 0)
  val uiEffect: SharedFlow&lt;ViewEffectWrapper&lt;LoginViewEffect&gt;&gt; = _uiEffect
  </code></pre>