Quantcast
Channel: Akka Libraries - Discussion Forum for Akka technologies
Viewing all articles
Browse latest Browse all 1365

Akka stream Source only change the internal state of the elements

$
0
0

Current I should use map method to achieve it:
Source<MyObject, NotUsed> source = Source.single(myObject).map(myObj → {
//1.change internal state of the object
//2.return the object itself
myObj.setInternalState(“newState”)
return myObj;
});

//Any existing method could return the element itself, and receive an “Consumer” that could change the internal state of it. (suppose it’s called xxx)
Source<MyObject, NotUsed> source = Source.single(myObject).xxx(myObj → {
myObj.setInternalState(“newState”);
});

1 post - 1 participant

Read full topic


Viewing all articles
Browse latest Browse all 1365

Trending Articles