Package org.bsc.async

Interface FlowGenerator


public interface FlowGenerator
Provides methods for converting between FlowGenerator and various Flow.Publisher types.
Since:
3.0.0
  • Method Details

    • fromPublisher

      static <T, P extends Flow.Publisher<T>> AsyncGenerator<T> fromPublisher(P publisher)
      Creates an AsyncGenerator from a Flow.Publisher.
      Type Parameters:
      T - the type of item emitted by the publisher
      P - the type of the publisher
      Parameters:
      publisher - the publisher to subscribe to for retrieving items asynchronously
      Returns:
      an AsyncGenerator that emits items from the publisher
    • toPublisher

      static <T> Flow.Publisher<T> toPublisher(AsyncGenerator<T> generator)
      Converts an AsyncGenerator into a Flow.Publisher.
      Type Parameters:
      T - the type of elements emitted by the publisher
      Parameters:
      generator - the async generator to convert
      Returns:
      a flow publisher