This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import akka.stream.scaladsl.FlexiMerge.{ReadAny, MergeLogic} | |
import akka.stream.{Attributes, FanInShape2} | |
import akka.stream.scaladsl.FlexiMerge | |
class BypassingMerge[A, B] extends FlexiMerge[A, FanInShape2[A, B, A]](new FanInShape2("BMerge"), Attributes.name("BMerge")) { | |
def createMergeLogic(p: PortT): MergeLogic[A] = new MergeLogic[A] { | |
override def initialState = | |
State[Any](ReadAny(p)) { (ctx, input, element) => | |
if (input eq p.in0) | |
ctx.emit(element.asInstanceOf[A]) | |
SameState | |
} | |
} | |
} | |
object BypassingMerge { | |
def apply[A,B]() = new BypassingMerge[A,B] | |
} |
Yup, looks good. One more thing: you can make this an object
, no need to allocate a new one for every use.
@rkuhn it has generic parameters A
and B
... ?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
2.0 correct version :