title: Create StateFlow from SharedFlow
body: <p>I have an object where I wish to create hot StateFlow objects from a filtered cold SharedFlow. The intent is that the SharedFlow is an event channel of data changes, but all data can be retrieved to get the current state. This means for a given field, I can find the current state, and then monitor the SharedFlow to get state changes.</p>
  <p>I would like to provide an API that (as an example) converts the SharedFlow into a StateFlow in a manner as follows:</p>
  <pre class="lang-kotlin prettyprint-override"><code>var myVariable = DEFAULT_VALUE
  val mySharedFlow = MutableSharedFlow&lt;Int&gt;()
  
  val myStateFlow = mySharedFlow
                      .filter { it &lt; 42 }
                      .asStateFlow(myVariable)// &lt;- Convert to a StateFlow given a default value
  </code></pre>
  <p>This is obviously an overly simplified example, but my situation is more complex, and currently I have to invoke a function when ever a field changes, but currently I do the following:</p>
  <pre class="lang-kotlin prettyprint-override"><code>myObj.onChange.collect(handler)
  handler(myObj.getCurrentValue)
  
  fun handler(data: Int) {
      // Handle data change
  }
  </code></pre>
  <p>But I would prefer to use a Hot StateFlow and remove the need for the second function call. Especially since many consumers of this are small bits of code (mostly just a single expression) that do not need to be in their own function context, and should just be simple lambdas.</p>