Skip to content

Instantly share code, notes, and snippets.

@iref
Last active January 17, 2017 15:09
Show Gist options
  • Save iref/983e310374da0852b4667dcbbddd513a to your computer and use it in GitHub Desktop.
Save iref/983e310374da0852b4667dcbbddd513a to your computer and use it in GitHub Desktop.
final class Reporter(scheduler: Scheduler) extends Observable[Payload] {
implicit val s = scheduler
// TODO define overflow strategy.
private val subject = ConcurrentSubject.publish[Payload]()
def unsafeSubscribeFn(subscriber: Subscriber[Payload]): Cancelable = {
subject.unsafeSubscribeFn(subscriber)
}
post("/endpoint") { request =>
val payload = parsePayload(request)
subject.onNext(payload)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment