/// <summary> /// Converts this Flow to a <see cref="IRunnableGraph{TMat}"/> that materializes to a Reactive Streams <see cref="IProcessor{T1,T2}"/> /// which implements the operations encapsulated by this Flow. Every materialization results in a new Processor /// instance, i.e. the returned <see cref="IRunnableGraph{TMat}"/> is reusable. /// </summary> /// <returns>A <see cref="IRunnableGraph{TMat}"/> that materializes to a <see cref="IProcessor{T1,T2}"/> when Run() is called on it.</returns> public IRunnableGraph <IProcessor <TIn, TOut> > ToProcessor() => Source.AsSubscriber <TIn>() .Via(this) .ToMaterialized(Sink.AsPublisher <TOut>(false), Keep.Both) .MapMaterializedValue(t => new FlowProcessor <TIn, TOut>(t.Item1, t.Item2) as IProcessor <TIn, TOut>);
/// <summary> /// Materializes this Sink immediately. /// /// Useful for when you need a materialized value of a Sink when handing it out to someone to materialize it for you. /// </summary> /// <param name="materializer">The materializer.</param> /// <returns>A tuple containing the (1) materialized value and (2) a new <see cref="Sink"/> /// that can be used to consume elements from the newly materialized <see cref="Sink"/>.</returns> public Tuple <TMat, Sink <TIn, NotUsed> > PreMaterialize(IMaterializer materializer) { var sub = Source.AsSubscriber <TIn>().ToMaterialized(this, Keep.Both).Run(materializer); return(Tuple.Create(sub.Item2, Sink.FromSubscriber(sub.Item1))); }