title: How to react to upstream completion in my flow?
body: <p>Suppose there's an Akka stream flow defined like this:</p>
  
  <pre><code>def tee = {
    var writer: Writer = ???
  
    Flow.fromFunction[String, String] { msg =&gt;
      writer.write(msg)
      msg
    }
  }
  </code></pre>
  
  <p>When the upstream is finished it needs to flush an close the writer. Is there a way to do it without resorting to <code>GraphStageLogic</code> etc as described here <a href="https://doc.akka.io/docs/akka/current/stream/stream-customize.html" rel="nofollow noreferrer">https://doc.akka.io/docs/akka/current/stream/stream-customize.html</a>?</p>