Skip to content

Commit

Permalink
API: Default emitOnce param to false in EventStream.{fromSeq, fromVal…
Browse files Browse the repository at this point in the history
…ue, fromTry}

Fixes #58
  • Loading branch information
raquo committed Jan 5, 2021
1 parent d4d33da commit 707ea07
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ object EventStream {

/** @param emitOnce if true, the event will be emitted at most one time.
* If false, the event will be emitted every time the stream is started. */
def fromSeq[A](events: Seq[A], emitOnce: Boolean): EventStream[A] = {
def fromSeq[A](events: Seq[A], emitOnce: Boolean = false): EventStream[A] = {
fromCustomSource[A](
shouldStart = startIndex => if (emitOnce) startIndex == 1 else true,
start = (fireEvent, _, _, _) => events.foreach(fireEvent),
Expand All @@ -175,7 +175,7 @@ object EventStream {

/** @param emitOnce if true, the event will be emitted at most one time.
* If false, the event will be emitted every time the stream is started. */
def fromValue[A](event: A, emitOnce: Boolean): EventStream[A] = {
def fromValue[A](event: A, emitOnce: Boolean = false): EventStream[A] = {
fromCustomSource[A](
shouldStart = startIndex => if (emitOnce) startIndex == 1 else true,
start = (fireEvent, _, _, _) => fireEvent(event),
Expand All @@ -185,7 +185,7 @@ object EventStream {

/** @param emitOnce if true, the event will be emitted at most one time.
* If false, the event will be emitted every time the stream is started. */
def fromTry[A](value: Try[A], emitOnce: Boolean): EventStream[A] = {
def fromTry[A](value: Try[A], emitOnce: Boolean = false): EventStream[A] = {
fromCustomSource[A](
shouldStart = startIndex => if (emitOnce) startIndex == 1 else true,
start = (fireEvent, fireError, _, _) => value.fold(fireError, fireEvent),
Expand Down

0 comments on commit 707ea07

Please sign in to comment.