19452: Contramap and fromFunction

This commit is contained in:
Alois Cochard 2016-02-10 12:18:24 +01:00 committed by Endre Sándor Varga
parent d9b47c3a8d
commit 6c69fba61e
8 changed files with 71 additions and 3 deletions

View file

@ -284,6 +284,12 @@ object Flow {
*/
def apply[T]: Flow[T, T, NotUsed] = identity.asInstanceOf[Flow[T, T, NotUsed]]
/**
* Creates a [Flow] which will use the given function to transform its inputs to outputs. It is equivalent
* to `Flow[T].map(f)`
*/
def fromFunction[A, B](f: A B): Flow[A, B, NotUsed] = apply[A].map(f)
/**
* A graph with the shape of a flow logically is a flow, this method makes
* it so also in type.