reactive
reactive copied to clipboard
Discuss: finite event streams, event data type
Making event streams finite opens a lot of doors for new methods and capabilities on event streams. @nafg you've mentioned to me you like what bacon.js
does, so following suit, we could have an Event
data type along the lines of
/** base event type */
sealed trait Event[+T]
/** sent when `fire` is called */
case class Next[+T](item: T) extends Event[T] //aka Fire
/** maybe unnecessary for us, but represents an event error */
case class Error(cause: Throwable) extends Event[Nothing]
/** sent when the eventstream is finished, or when `stop` or
some similar method gets called */
case object Done extends Event[Nothing]
/** this is how bacon.js sends the "current" value for their
equivalent of a Signal, when an observer subscribes to it */
case object Initial[+T](item: T) extends Event[T]
Supposing eventstreams used Event[T]
under the hood, we could implement things like ++
for stream concatenation, def end: Future[Time]
, and potentially clean up the Signal
API by removing the current
method as you had mentioned in conversation previously.