Skip to content

Instantly share code, notes, and snippets.

@wjlow
Created May 28, 2018 06:09
Show Gist options
  • Save wjlow/df7cf9a5eb714f96f16ce5285fbd2a55 to your computer and use it in GitHub Desktop.
Save wjlow/df7cf9a5eb714f96f16ce5285fbd2a55 to your computer and use it in GitHub Desktop.
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