Skip to content

Commit

Permalink
adding missing .distincts on signals, eliminate bad .flatMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Iurii Malchenko committed Aug 7, 2023
1 parent 8944663 commit 3f7456c
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ lazy val frontrouteSiteVersion: String = IO.read(file("website/.frontroute-versi
lazy val thisVersionSitePrefix = s"/v/$frontrouteSiteVersion/"

lazy val vars = Seq(
"frontrouteVersion" -> "0.18.0",
"frontrouteVersion" -> "0.18.1",
"laminarVersion" -> "16.0.0",
"scalajsVersion" -> "1.13.2",
"scala3version" -> "3.3.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class BrowserLocationProvider(
) extends LocationProvider {

private val currentVar = Var(Option.empty[Location])
val current: Signal[Option[Location]] = currentVar.signal
val current: Signal[Option[Location]] = currentVar.signal.distinct

def start()(implicit owner: Owner): Subscription = {
EventStream
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ private[frontroute] class LocationState(
val routerState: RouterStateRef,
) {

private val remainingVar = Var(Option.empty[Location])
val remaining: StrictSignal[Option[Location]] = remainingVar.signal
private val remainingVar = Var(Option.empty[Location])
val remaining: Signal[Option[Location]] = remainingVar.signal.distinct

def setRemaining(remaining: Option[Location]): Unit = remainingVar.set(remaining)

Expand Down
5 changes: 1 addition & 4 deletions modules/frontroute/src/main/scala/frontroute/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,7 @@ package object frontroute extends PathMatchers with Directives with ApplyConvert
Seq(
onMountCallback { (ctx: MountContext[ReactiveHtmlElement[Ref]]) =>
val locationState = LocationState.closestOrFail(ctx.thisNode.ref)
val consumed =
EventStream.fromValue(()).delay(0).flatMap { _ =>
locationState.consumed
}
val consumed = EventStream.fromValue(()).delay(0).sample(locationState.consumed)

val _ = ReactiveElement.bindObserver(ctx.thisNode, consumed)(consumedVar.writer)
},
Expand Down

0 comments on commit 3f7456c

Please sign in to comment.