Hi Igmar,
You can do a map on the source and pass the new returned Source as the
second parameter to Flow.fromSinkAndSource instead of the original source.
Something like this (untested):
final Source<X, NotUsed> source = Source.range(1, 100).map(v -> new X());
final Sink<X, CompletionStage<Done>> sink = Sink.foreach(v ->
System.out.println(v));
final Flow<X, Integer, NotUsed> flow = Flow.fromSinkAndSource(sink, source);
Hope that helps,
MichaĆ
On 03/05/17 10:42, Igmar Palsenberg wrote:
Hi,
I'm starting to learn the basics of Akka Streams, and I have this :
final Source<Integer, NotUsed> source = Source.range(1, 100);
final Sink<X, CompletionStage<Done>> sink = Sink.foreach(v ->
System.out.println(v));
final Flow<X, Integer, NotUsed> flow = Flow.fromSinkAndSource(sink,
source);
What I'v read from the docs :
Flow
A processing stage which has /exactly one input and output/, which
connects its up- and downstreams by transforming the data elements
flowing through it.
If I understand correctly, I could transform an Integer to an X. A map
on flow doesn't work, since that requires an Integer to be returned. I
tried :
Flow<X, X, NotUsed> x = flow.map(v -> return new X() );
but then I can't materialize the flow using runWith, since it requires
both a sink and a source (why ?? Since fromSinkAndSource already
provided that).
Can someone shed a light on this ?
Regards,
Igmar
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google
Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send
an email to akka-user+unsubscr...@googlegroups.com
<mailto:akka-user+unsubscr...@googlegroups.com>.
To post to this group, send email to akka-user@googlegroups.com
<mailto:akka-user@googlegroups.com>.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
--
Signature
<http://www.openbet.com/> Michal Borowiecki
Senior Software Engineer L4
T: +44 208 742 1600
+44 203 249 8448
E: michal.borowie...@openbet.com
W: www.openbet.com <http://www.openbet.com/>
OpenBet Ltd
Chiswick Park Building 9
566 Chiswick High Rd
London
W4 5XT
UK
<https://www.openbet.com/email_promo>
This message is confidential and intended only for the addressee. If you
have received this message in error, please immediately notify the
postmas...@openbet.com <mailto:postmas...@openbet.com> and delete it
from your system as well as any copies. The content of e-mails as well
as traffic data may be monitored by OpenBet for employment and security
purposes. To protect the environment please do not print this e-mail
unless necessary. OpenBet Ltd. Registered Office: Chiswick Park Building
9, 566 Chiswick High Road, London, W4 5XT, United Kingdom. A company
registered in England and Wales. Registered no. 3134634. VAT no.
GB927523612
--
Read the docs: http://akka.io/docs/
Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.