Instantly share code, notes, and snippets.

Embed
What would you like to do?
class MemorySink[A] extends Sink[A]{
  private var buffer: Vector[A] = Vector.empty

  def replay: Vector[A] = buffer

  def last: Option[A] = buffer.lastOption

  override def apply(a: A): Async[Unit] = Async {
    buffer :+= a
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment