Skip to content

Commit

Permalink
rename asIf to toggle and not to negated
Browse files Browse the repository at this point in the history
  • Loading branch information
cornerman committed Oct 24, 2022
1 parent 3308024 commit f26a9dc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions colibri/src/main/scala/colibri/Observable.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1680,14 +1680,14 @@ object Observable {
}

@inline implicit class BooleanOperations(private val source: Observable[Boolean]) extends AnyVal {
@inline def asIf[A](ifTrue: => A, ifFalse: A): Observable[A] = source.map {
@inline def toggle[A](ifTrue: => A, ifFalse: A): Observable[A] = source.map {
case true => ifTrue
case false => ifFalse
}

@inline def asIf[A: Monoid](ifTrue: => A): Observable[A] = asIf(ifTrue, Monoid[A].empty)
@inline def toggle[A: Monoid](ifTrue: => A): Observable[A] = toggle(ifTrue, Monoid[A].empty)

@inline def not: Observable[Boolean] = source.map(x => !x)
@inline def negated: Observable[Boolean] = source.map(x => !x)
}

@inline implicit class IterableOperations[A](private val source: Observable[Iterable[A]]) extends AnyVal {
Expand Down
10 changes: 5 additions & 5 deletions reactive/src/test/scala/colibri/ReactiveSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -612,12 +612,12 @@ class ReactiveSpec extends AsyncFlatSpec with Matchers {
case class EventB(s: String) extends Event

Owned(SyncIO {
val eventVar = Var[Event](EventA(0))
val eventNotAVar = Var[Event](EventB(""))
val eventVar: Var[Event] = Var[Event](EventA(0))
val eventNotAVar: Var[Event] = Var[Event](EventB(""))

val eventAVarOption = eventVar.prism(GenPrism[Event, EventA])
val eventAVarOption2 = eventVar.subType[EventA]
val eventNotAVarOption = eventNotAVar.prism(GenPrism[Event, EventA])
val eventAVarOption: Option[Var[EventA]] = eventVar.prism(GenPrism[Event, EventA])
val eventAVarOption2: Option[Var[EventA]] = eventVar.subType[EventA]
val eventNotAVarOption: Option[Var[EventA]] = eventNotAVar.prism(GenPrism[Event, EventA])

eventAVarOption.isDefined shouldBe true
eventAVarOption2.isDefined shouldBe true
Expand Down

0 comments on commit f26a9dc

Please sign in to comment.