Skip to content

Commit

Permalink
remove temporary nowarns
Browse files Browse the repository at this point in the history
  • Loading branch information
rmgk committed Mar 2, 2024
1 parent 3b54852 commit c01ca08
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ trait Event[+T] extends MacroAccess[Option[T]] with Disconnectable {
* @group conversion
*/
final def iterate[A](init: A)(f: A => A)(implicit ticket: CreationTicket[State]): Signal[A] =
fold(init)((acc, _) => f(acc)): @nowarn
fold(init)((acc, _) => f(acc))

/** Counts the occurrences of the event.
* The argument of the event is discarded.
Expand All @@ -133,19 +133,19 @@ trait Event[+T] extends MacroAccess[Option[T]] with Disconnectable {
* @group conversion
*/
final def hold[A >: T](init: A)(implicit ticket: CreationTicket[State]): Signal[A] =
fold(init)((_, v) => v): @nowarn
fold(init)((_, v) => v)

/** returns a signal holding the latest value of the event.
* @group conversion
*/
final def hold[A >: T]()(implicit ticket: CreationTicket[State]): Signal[A] =
Fold(throw EmptySignalControlThrowable(info))(this act { v => v }): @nowarn
Fold(throw EmptySignalControlThrowable(info))(this act { v => v })

/** Holds the latest value of an event as an Option, None before the first event occured
* @group conversion
*/
final def holdOption[A >: T]()(implicit ticket: CreationTicket[State]): Signal[Option[A]] =
fold(Option.empty[A]) { (_, v) => Some(v) }: @nowarn
fold(Option.empty[A]) { (_, v) => Some(v) }

/** Returns a signal which holds the last n events in a list. At the beginning the
* list increases in size up to when n values are available
Expand All @@ -157,22 +157,22 @@ trait Event[+T] extends MacroAccess[Option[T]] with Disconnectable {
else
fold(Queue[A]()) { (queue: Queue[A], v: T) =>
if (queue.lengthCompare(n) >= 0) queue.tail.enqueue(v) else queue.enqueue(v)
}: @nowarn
}
}

/** collects events resulting in a variable holding a list of all values.
* @group conversion
*/
final def list[A >: T]()(implicit ticket: CreationTicket[State]): Signal[List[A]] =
fold(List[A]())((acc, v) => v :: acc): @nowarn
fold(List[A]())((acc, v) => v :: acc)

/** Switch back and forth between two signals on occurrence of event e
* @group conversion
*/
final def toggle[A](a: Signal[A], b: Signal[A])(implicit ticket: CreationTicket[State]): Signal[A] =
ticket.scope.embedCreation { ict =>
val switched: Signal[Boolean] = iterate(false) { !_ }(using ict)
Signal.dynamic(using ict) { if switched.value then b.value else a.value }: @nowarn
Signal.dynamic(using ict) { if switched.value then b.value else a.value }
}

/** Filters the event, only propagating the value when the filter is true.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,33 @@ object Flatten {
implicit def flattenImplicitForsignal[B](using CreationTicket[State]): Flatten[
Signal[Signal[B]],
Signal[B]
] = sig => Signal.dynamic(sig.value.value): @nowarn
] = sig => Signal.dynamic(sig.value.value)

/** Flatten a Signal[Array[Signal[B]\]\] into a Signal[Array[B]\] where the new Signal updates whenever any of the inner or the outer signal updates */
implicit def flattenImplicitForArraySignals[B: ClassTag, Sig[U] <: Signal[U]](using
CreationTicket[State]
): Flatten[
Signal[Array[Sig[B]]],
Signal[Array[B]]
] = sig => Signal.dynamic { sig.value.map(_.value) }: @nowarn
] = sig => Signal.dynamic { sig.value.map(_.value) }

/** Flatten a Signal[Option[Signal[B]\]\] into a Signal[Option[B]\] where the new Signal updates whenever any of the inner or the outer signal updates */
implicit def flattenImplicitForOptionSignal[B, Sig[U] <: Signal[U]](using CreationTicket[State]): Flatten[
Signal[Option[Sig[B]]],
Signal[Option[B]]
] = sig => Signal.dynamic { sig.value.map { _.value } }: @nowarn
] = sig => Signal.dynamic { sig.value.map { _.value } }

/** Flatten a Signal[Event[B]]\] into a Event[B] where the new Event fires whenever the current inner event fires */
implicit def flattenImplicitForevent[A, B, Evnt[A1] <: Event[A1]](using CreationTicket[State]): Flatten[
Signal[Evnt[B]],
Event[B]
] = sig => Event.dynamic(sig.value.value): @nowarn
] = sig => Event.dynamic(sig.value.value)

/** Flatten a Event[Option[B]\] into a Event[B] that fires whenever the inner option is defined. */
implicit def flattenImplicitForoption[A, B](using CreationTicket[State]): Flatten[
Event[Option[B]],
Event[B]
] = event => Event.static { event.value.flatten }: @nowarn
] = event => Event.static { event.value.flatten }

/** Flatten a Signal[Traversable[Signal[B]\]\] into a Signal[Traversable[B]\] where the new Signal updates whenever any of the inner or the outer signal updates */
implicit def flattenImplicitForIterableSignals[
Expand All @@ -56,7 +56,7 @@ object Flatten {
](using CreationTicket[State]): Flatten[
Signal[Iter[Sig[B]]],
Signal[Iter[B]]
] = sig => Signal.dynamic { sig.value.map { (r: Signal[B]) => r.value } }: @nowarn
] = sig => Signal.dynamic { sig.value.map { (r: Signal[B]) => r.value } }

/** Flatten a Signal[Traversable[Event[B]\]\] into a Event[B]. The new Event fires the value of any inner firing Event.
* If multiple inner Events fire, the first one in iteration order is selected.
Expand All @@ -72,7 +72,7 @@ object Flatten {
Event.dynamic {
val all = sig.value map { _.value }
all.collectFirst { case Some(e) => e }
}: @nowarn
}

/** Flatten a Signal[Traversable[Event[B]\]\] into a Event[Traversable[Option[B]\]\] where the new Event fires whenever any of the inner events fire */
def traversableOfAllOccuringEventValues[
Expand All @@ -86,5 +86,5 @@ object Flatten {
Event.dynamic {
val all = sig.value map { (r: Event[B]) => r.value }
if (all.exists(_.isDefined)) Some(all) else None
}: @nowarn
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ trait Signal[+T] extends Disconnectable with MacroAccess[T] with ReSource {
catch {
case NonFatal(e) => onFailure.applyOrElse[Throwable, R](e, throw _)
}
}: @nowarn
}

/** Adds another error message in case this signal is empty, also disallows handling exceptions in observers */
final def abortOnError(message: String)(implicit ticket: CreationTicket[State]): Signal[T] =
Expand All @@ -98,7 +98,7 @@ trait Signal[+T] extends Disconnectable with MacroAccess[T] with ReSource {
catch {
case EmptySignalControlThrowable => value
}
}: @nowarn
}

/** Flattens the inner value.
* @group operator
Expand Down Expand Up @@ -214,12 +214,12 @@ object Signal {
}

def lift[A1, B](n1: Signal[A1])(fun: A1 => B)(using CreationTicket[State]): Signal[B] =
Signal { fun(n1.value) }: @nowarn
Signal { fun(n1.value) }

def lift[A1, A2, B](n1: Signal[A1], n2: Signal[A2])(fun: (A1, A2) => B)(using
CreationTicket[State]
): Signal[B] = {
Signal { fun(n1.value, n2.value) }: @nowarn
Signal { fun(n1.value, n2.value) }
}

}

0 comments on commit c01ca08

Please sign in to comment.