{"action":"created","issue":{"url":"https://api.github.com/repos/akka/akka/issues/19452","labels_url":"https://api.github.com/repos/akka/akka/issues/19452/labels{/name}","comments_url":"https://api.github.com/repos/akka/akka/issues/19452/comments","events_url":"https://api.github.com/repos/akka/akka/issues/19452/events","html_url":"https://github.com/akka/akka/issues/19452","id":126656670,"number":19452,"title":"Add `Flow.auto` and `Sink.contramap`.","user":{"login":"aloiscochard","id":215476,"avatar_url":"https://avatars.githubusercontent.com/u/215476?v=3","gravatar_id":"","url":"https://api.github.com/users/aloiscochard","html_url":"https://github.com/aloiscochard","followers_url":"https://api.github.com/users/aloiscochard/followers","following_url":"https://api.github.com/users/aloiscochard/following{/other_user}","gists_url":"https://api.github.com/users/aloiscochard/gists{/gist_id}","starred_url":"https://api.github.com/users/aloiscochard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aloiscochard/subscriptions","organizations_url":"https://api.github.com/users/aloiscochard/orgs","repos_url":"https://api.github.com/users/aloiscochard/repos","events_url":"https://api.github.com/users/aloiscochard/events{/privacy}","received_events_url":"https://api.github.com/users/aloiscochard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/akka/akka/labels/0%20-%20new","name":"0 - new","color":"ffffff"},{"url":"https://api.github.com/repos/akka/akka/labels/t:stream","name":"t:stream","color":"cccccc"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":14,"created_at":"2016-01-14T13:40:09Z","updated_at":"2016-01-14T21:34:31Z","closed_at":null,"body":"I would like to suggest a few combinators, I already have a PR ready with those:\r\n\r\nFlow.auto (name taken from an other streaming lib I was using, I'm open to a suggestion that fit better the naming scheme of the project)\r\n```\r\n  /**\r\n   * Helper to create `Flow` from a function.\r\n   */\r\n  def auto[A, B](f: A ⇒ B): Flow[A, B, Unit] = apply[A].map(f)\r\n```\r\n\r\nSink.contramap\r\n```\r\n  def contramap[In2](f: In2 ⇒ In): Sink[In2, Mat] = Flow.auto(f).toMat(this) { (_, m) ⇒ m }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/akka/akka/issues/comments/171786843","html_url":"https://github.com/akka/akka/issues/19452#issuecomment-171786843","issue_url":"https://api.github.com/repos/akka/akka/issues/19452","id":171786843,"user":{"login":"rkuhn","id":470469,"avatar_url":"https://avatars.githubusercontent.com/u/470469?v=3","gravatar_id":"","url":"https://api.github.com/users/rkuhn","html_url":"https://github.com/rkuhn","followers_url":"https://api.github.com/users/rkuhn/followers","following_url":"https://api.github.com/users/rkuhn/following{/other_user}","gists_url":"https://api.github.com/users/rkuhn/gists{/gist_id}","starred_url":"https://api.github.com/users/rkuhn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rkuhn/subscriptions","organizations_url":"https://api.github.com/users/rkuhn/orgs","repos_url":"https://api.github.com/users/rkuhn/repos","events_url":"https://api.github.com/users/rkuhn/events{/privacy}","received_events_url":"https://api.github.com/users/rkuhn/received_events","type":"User","site_admin":false},"created_at":"2016-01-14T21:34:31Z","updated_at":"2016-01-14T21:34:31Z","body":"Yes, that is what I meant: a Sink can grow only in one direction, so there we might contemplate it—while Flow is pretty much locked down to left-to-right notation. This is also less of a problem because Sink does not have combinators right now anyway, so adding one is not that inconsistent as it would be for Flow.\r\n\r\nI’d prefer the name lifting a function into a Flow to be `fromFunction` (to be symmetrical with BidiFlow). A PR with that plus `Sink.{prepend,contramap}` would be welcome."}}