The presence of akka streams Sink:
Sink
val sink: Sink[Foo, Any] = ???
and function from Barto Foo:
Bar
Foo
val f: Bar => Foo = ???
I want to contramap (contrast card) Sinkwith f, to get the receiver type Sink[Bar, Any], but can not find a simple method in the library. How to achieve what I need?
f
Sink[Bar, Any]
It turned out to be pretty simple.
Create Flowaccepting Bars:
Flow
val flow: Flow[Bar, Bar, Unit] = Flow[Bar]
and compare it with the results of <pipelining fto the original sink:
sink
val sink2: Sink[Bar, Unit] = flow.map(f).to(sink)
With akka-streamsversion, 2.4.Xthis is even simpler:
akka-streams
2.4.X
val sink3: Sink[Bar, Future[Done]] = sink.contramap(f)
Source: https://habr.com/ru/post/1619963/More articles:Scala Slick: Stream Never Ends - scalahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1619959/packing-nonreactive-libraries-to-reactive-wrappers&usg=ALkJrhj2VVqRf9phdToVNpfAy3sIQ62cgwДержите объект "неподвижным" перед камерой (Google Cardboard + Unity) - c#Количество байтов, передаваемых TcpClient через NetworkStream BinaryReader/BinaryWriter - c#Inline block elements do not align vertically with ellipsis overflow - htmlorientation change in Bootstrap Datetimepicker - javascriptAn application related to work, but not showing changes in dumpsys - androidZeroMQ: REQ / REP with big messages - c ++What is the maximum number of channels a selector can select? - java: target modalDialog не открывается - javascriptAll Articles