object SignallingRef
- Companion:
- class
- Source:
- Signal.scala
Value members
Concrete methods
Builds a SignallingRef
value for data types that are Concurrent
.
Builds a SignallingRef
value for data types that are Concurrent
.
This builder uses the Partially-Applied Type technique.
SignallingRef[IO].of(10L) <-> SignallingRef.of[IO, Long](10L)
- See also:
- Source:
- Signal.scala
State.this._1
case1=>
State.this._2
case2=>
State.this._3
case_=>
thrownewIndexOutOfBoundsException(n.toString())
}
}
objectStateextendsAnyRefwithProduct{
overridedeftoString:String="State"
typeMirroredMonoType
deffromProduct(`x$0₃`:Product):MirroredMonoType=newState(`x$0₃`.productElement(0).$asInstanceOf$[A],`x$0₃`.productElement(1).$asInstanceOf$[Long],`x$0₃`.productElement(2).$asInstanceOf$[LongMap[Deferred[F,Tuple2[A,Long]]]])
}
toFunctorOps[F,Tuple2[Ref[F,State],Ref[F,Long]]](catsSyntaxSemigroupal[F,Ref[F,State]](F.ref[State](State.apply(initial,0L,LongMap.empty[Deferred[F,Tuple2[A,Long]]])))(F).product[Ref[F,Long]](F.ref[Long](1L)))(F).map[SignallingRef[F,A]](((x$1:Tuple2[Ref[F,State],Ref[F,Long]])=>x$1match{
caseTuple2(state,ids)=>
defnewId:F[Long]=ids.getAndUpdate(((_$11:Long)=>_$11.+(1)))
defupdateAndNotify[B](state:State,f:Function1[A,Tuple2[A,B]]):Tuple2[State,F[B]]={
val$2$:Tuple2[A,B]=(f.apply(state.value):@unchecked)match{
caseTuple2(newValue,result)=>
Tuple2.apply[A,B](newValue,result)
}
val`newValue₂`:A=$2$._1
val`result₂`:B=$2$._2
val`lastUpdate₂`:Long=state.lastUpdate.+(1)
valnewState:State=State.apply(`newValue₂`,`lastUpdate₂`,LongMap.empty[Deferred[F,Tuple2[A,Long]]])
valnotifyListeners:F[Unit]=toFoldableOps[[A>:Nothing<:Any]=>Vector[A],Deferred[F,Tuple2[A,Long]]](state.listeners.values.toVector)(catsTraverseForVector).traverse_[F,Boolean](((listener:Deferred[F,Tuple2[A,Long]])=>listener.complete(ArrowAssoc[A](`newValue₂`).->[Long](`lastUpdate₂`))))(F)
ArrowAssoc[State](newState).->[F[B]](toFunctorOps[F,Unit](notifyListeners)(F).as[B](`result₂`))
}
{
finalclass$anon()extendsSignallingRef[F,A]{
defget:F[A]=toFunctorOps[F,State](`state₂`.get)(F).map[A](((_$12:State)=>_$12.value))
defcontinuous:Stream[F,A]=Stream.repeatEval[F,A]($anon.this.get)
defdiscrete:Stream[F,A]={
defgo(id:Long,lastSeen:Long):Stream[F,A]={
defgetNext:F[Tuple2[A,Long]]=toFlatMapOps[F,Deferred[F,Tuple2[A,Long]]](F.deferred[Tuple2[A,Long]])(F).flatMap[Tuple2[A,Long]](((wait:Deferred[F,Tuple2[A,Long]])=>catsSyntaxFlatten[F,Tuple2[A,Long]](`state₂`.modify[F[Tuple2[A,Long]]](((`x$1₂`:State)=>`x$1₂`match{
casestate@State(value,lastUpdate,listeners)=>
if(`lastUpdate₃`.!=(lastSeen))ArrowAssoc[State](`state₃`).->[F[Tuple2[A,Long]]](catsSyntaxApplicativeId[Tuple2[A,Long]](ArrowAssoc[A](`value₂`).->[Long](`lastUpdate₃`)).pure[F](F))elseArrowAssoc[State]({
vallisteners$1:LongMap[Deferred[F,Tuple2[A,Long]]]=`listeners₂`.+[Deferred[F,Tuple2[A,Long]]](ArrowAssoc[Long](id).->[Deferred[F,Tuple2[A,Long]]](wait))
valvalue$1:A@uncheckedVariance=`state₃`.copy$default$1
vallastUpdate$1:Long@uncheckedVariance=`state₃`.copy$default$2
`state₃`.copy(value$1,lastUpdate$1,listeners=listeners$1)
}).->[F[Tuple2[A,Long]]](wait.get)
})))(F).flatten(F)))
Stream.eval[F,Tuple2[A,Long]](getNext).flatMap[F,A](((`x$1₃`:Tuple2[A,Long])=>`x$1₃`match{
caseTuple2(a,lastUpdate)=>
Stream.emit[[x>:Nothing<:Any]=>Pure[x],A](a).++[F,A](go(id,lastSeen=`lastUpdate₄`))
}))(value)
}
defcleanup(`id₂`:Long):F[Unit]=`state₂`.update(((s:State)=>{
vallisteners$2:LongMap[Deferred[F,Tuple2[A,Long]]]=s.listeners.-(`id₂`)
valvalue$2:A@uncheckedVariance=s.copy$default$1
vallastUpdate$2:Long@uncheckedVariance=s.copy$default$2
s.copy(value$2,lastUpdate$2,listeners=listeners$2)
}))
Stream.bracket[F,Long](newId)(((`id₃`:Long)=>cleanup(`id₃`))).flatMap[F,A](((`id₄`:Long)=>Stream.eval[F,State](`state₂`.get).flatMap[F,A](((`state₄`:State)=>Stream.emit[[x>:Nothing<:Any]=>Pure[x],A](`state₄`.value).++[F,A](go(`id₄`,`state₄`.lastUpdate))))(value)))(value)
}
defset(`a₂`:A):F[Unit]=$anon.this.update(((_$13:A)=>`a₂`))
defupdate(`f₂`:Function1[A,A]):F[Unit]=$anon.this.modify[Unit](((`a₃`:A)=>Tuple2.apply[A,Unit](`f₂`.apply(`a₃`),())))
defmodify[B](`f₃`:Function1[A,Tuple2[A,B]]):F[B]=catsSyntaxFlatten[F,B](`state₂`.modify[F[B]](((_$14:State)=>updateAndNotify[B](_$14,`f₃`))))(F).flatten(F)
deftryModify[B](`f₄`:Function1[A,Tuple2[A,B]]):F[Option[B]]=toFlatMapOps[F,Option[F[B]]](`state₂`.tryModify[F[B]](((_$15:State)=>updateAndNotify[B](_$15,`f₄`))))(F).flatMap[Option[B]](((_$16:Option[F[B]])=>toTraverseOps[[A>:Nothing<:Any]=>Option[A],F[B]](_$16)(catsTraverseForOption).sequence[F,B](refl[F[B]],F)))
deftryUpdate(`f₅`:Function1[A,A]):F[Boolean]=toFunctorOps[F,Option[Unit]]($anon.this.tryModify[Unit](((`a₄`:A)=>Tuple2.apply[A,Unit](`f₅`.apply(`a₄`),()))))(F).map[Boolean](((_$17:Option[Unit])=>_$17.isDefined))
defaccess:F[Tuple2[A,Function1[A,F[Boolean]]]]=toFunctorOps[F,Tuple2[State,Function1[State,F[Boolean]]]](`state₂`.access)(F).map[Tuple2[A,Function1[A,F[Boolean]]]](((`x$1₄`:Tuple2[State,Function1[State,F[Boolean]]])=>`x$1₄`match{
caseTuple2(state,set)=>
valsetter:Function1[A,F[Boolean]]=((`newValue₃`:A)=>{
val$3$:Tuple2[State,F[Unit]]=(updateAndNotify[Unit](`state₅`,((_$18:A)=>Tuple2.apply[A,Unit](`newValue₃`,()))):@unchecked)match{
caseTuple2(newState,notifyListeners)=>
Tuple2.apply[State,F[Unit]](`newState₂`,`notifyListeners₂`)
}
val`newState₃`:State=$3$._1
val`notifyListeners₃`:F[Unit]=$3$._2
toFlatMapOps[F,Boolean](set.apply(`newState₃`))(F).flatTap[Unit](((succeeded:Boolean)=>catsSyntaxApplicativeByName[F,Unit](`notifyListeners₃`).whenA(succeeded)(F)))
})
Tuple2.apply[A,Function1[A,F[Boolean]]](`state₅`.value,setter)
}))
deftryModifyState[B](`state₆`:cats.data.State[A,B]):F[Option[B]]={
val`f₆`:Function1[A,Eval[Tuple2[A,B]]]=`state₆`.runF.value
$anon.this.tryModify[B](((`a₅`:A)=>`f₆`.apply(`a₅`).value))
}
defmodifyState[B](`state₇`:cats.data.State[A,B]):F[B]={
val`f₇`:Function1[A,Eval[Tuple2[A,B]]]=`state₇`.runF.value
$anon.this.modify[B](((`a₆`:A)=>`f₇`.apply(`a₆`).value))
}
}
(new$anon():SignallingRef[F,A])
}
}))
}" class="documentableAnchor">
def
State.this._1
case1=>
State.this._2
case2=>
State.this._3
case_=>
thrownewIndexOutOfBoundsException(n.toString())
}
}
objectStateextendsAnyRefwithProduct{
overridedeftoString:String="State"
typeMirroredMonoType
deffromProduct(`x$0₃`:Product):MirroredMonoType=newState(`x$0₃`.productElement(0).$asInstanceOf$[A],`x$0₃`.productElement(1).$asInstanceOf$[Long],`x$0₃`.productElement(2).$asInstanceOf$[LongMap[Deferred[F,Tuple2[A,Long]]]])
}
toFunctorOps[F,Tuple2[Ref[F,State],Ref[F,Long]]](catsSyntaxSemigroupal[F,Ref[F,State]](F.ref[State](State.apply(initial,0L,LongMap.empty[Deferred[F,Tuple2[A,Long]]])))(F).product[Ref[F,Long]](F.ref[Long](1L)))(F).map[SignallingRef[F,A]](((x$1:Tuple2[Ref[F,State],Ref[F,Long]])=>x$1match{
caseTuple2(state,ids)=>
defnewId:F[Long]=ids.getAndUpdate(((_$11:Long)=>_$11.+(1)))
defupdateAndNotify[B](state:State,f:Function1[A,Tuple2[A,B]]):Tuple2[State,F[B]]={
val$2$:Tuple2[A,B]=(f.apply(state.value):@unchecked)match{
caseTuple2(newValue,result)=>
Tuple2.apply[A,B](newValue,result)
}
val`newValue₂`:A=$2$._1
val`result₂`:B=$2$._2
val`lastUpdate₂`:Long=state.lastUpdate.+(1)
valnewState:State=State.apply(`newValue₂`,`lastUpdate₂`,LongMap.empty[Deferred[F,Tuple2[A,Long]]])
valnotifyListeners:F[Unit]=toFoldableOps[[A>:Nothing<:Any]=>Vector[A],Deferred[F,Tuple2[A,Long]]](state.listeners.values.toVector)(catsTraverseForVector).traverse_[F,Boolean](((listener:Deferred[F,Tuple2[A,Long]])=>listener.complete(ArrowAssoc[A](`newValue₂`).->[Long](`lastUpdate₂`))))(F)
ArrowAssoc[State](newState).->[F[B]](toFunctorOps[F,Unit](notifyListeners)(F).as[B](`result₂`))
}
{
finalclass$anon()extendsSignallingRef[F,A]{
defget:F[A]=toFunctorOps[F,State](`state₂`.get)(F).map[A](((_$12:State)=>_$12.value))
defcontinuous:Stream[F,A]=Stream.repeatEval[F,A]($anon.this.get)
defdiscrete:Stream[F,A]={
defgo(id:Long,lastSeen:Long):Stream[F,A]={
defgetNext:F[Tuple2[A,Long]]=toFlatMapOps[F,Deferred[F,Tuple2[A,Long]]](F.deferred[Tuple2[A,Long]])(F).flatMap[Tuple2[A,Long]](((wait:Deferred[F,Tuple2[A,Long]])=>catsSyntaxFlatten[F,Tuple2[A,Long]](`state₂`.modify[F[Tuple2[A,Long]]](((`x$1₂`:State)=>`x$1₂`match{
casestate@State(value,lastUpdate,listeners)=>
if(`lastUpdate₃`.!=(lastSeen))ArrowAssoc[State](`state₃`).->[F[Tuple2[A,Long]]](catsSyntaxApplicativeId[Tuple2[A,Long]](ArrowAssoc[A](`value₂`).->[Long](`lastUpdate₃`)).pure[F](F))elseArrowAssoc[State]({
vallisteners$1:LongMap[Deferred[F,Tuple2[A,Long]]]=`listeners₂`.+[Deferred[F,Tuple2[A,Long]]](ArrowAssoc[Long](id).->[Deferred[F,Tuple2[A,Long]]](wait))
valvalue$1:A@uncheckedVariance=`state₃`.copy$default$1
vallastUpdate$1:Long@uncheckedVariance=`state₃`.copy$default$2
`state₃`.copy(value$1,lastUpdate$1,listeners=listeners$1)
}).->[F[Tuple2[A,Long]]](wait.get)
})))(F).flatten(F)))
Stream.eval[F,Tuple2[A,Long]](getNext).flatMap[F,A](((`x$1₃`:Tuple2[A,Long])=>`x$1₃`match{
caseTuple2(a,lastUpdate)=>
Stream.emit[[x>:Nothing<:Any]=>Pure[x],A](a).++[F,A](go(id,lastSeen=`lastUpdate₄`))
}))(value)
}
defcleanup(`id₂`:Long):F[Unit]=`state₂`.update(((s:State)=>{
vallisteners$2:LongMap[Deferred[F,Tuple2[A,Long]]]=s.listeners.-(`id₂`)
valvalue$2:A@uncheckedVariance=s.copy$default$1
vallastUpdate$2:Long@uncheckedVariance=s.copy$default$2
s.copy(value$2,lastUpdate$2,listeners=listeners$2)
}))
Stream.bracket[F,Long](newId)(((`id₃`:Long)=>cleanup(`id₃`))).flatMap[F,A](((`id₄`:Long)=>Stream.eval[F,State](`state₂`.get).flatMap[F,A](((`state₄`:State)=>Stream.emit[[x>:Nothing<:Any]=>Pure[x],A](`state₄`.value).++[F,A](go(`id₄`,`state₄`.lastUpdate))))(value)))(value)
}
defset(`a₂`:A):F[Unit]=$anon.this.update(((_$13:A)=>`a₂`))
defupdate(`f₂`:Function1[A,A]):F[Unit]=$anon.this.modify[Unit](((`a₃`:A)=>Tuple2.apply[A,Unit](`f₂`.apply(`a₃`),())))
defmodify[B](`f₃`:Function1[A,Tuple2[A,B]]):F[B]=catsSyntaxFlatten[F,B](`state₂`.modify[F[B]](((_$14:State)=>updateAndNotify[B](_$14,`f₃`))))(F).flatten(F)
deftryModify[B](`f₄`:Function1[A,Tuple2[A,B]]):F[Option[B]]=toFlatMapOps[F,Option[F[B]]](`state₂`.tryModify[F[B]](((_$15:State)=>updateAndNotify[B](_$15,`f₄`))))(F).flatMap[Option[B]](((_$16:Option[F[B]])=>toTraverseOps[[A>:Nothing<:Any]=>Option[A],F[B]](_$16)(catsTraverseForOption).sequence[F,B](refl[F[B]],F)))
deftryUpdate(`f₅`:Function1[A,A]):F[Boolean]=toFunctorOps[F,Option[Unit]]($anon.this.tryModify[Unit](((`a₄`:A)=>Tuple2.apply[A,Unit](`f₅`.apply(`a₄`),()))))(F).map[Boolean](((_$17:Option[Unit])=>_$17.isDefined))
defaccess:F[Tuple2[A,Function1[A,F[Boolean]]]]=toFunctorOps[F,Tuple2[State,Function1[State,F[Boolean]]]](`state₂`.access)(F).map[Tuple2[A,Function1[A,F[Boolean]]]](((`x$1₄`:Tuple2[State,Function1[State,F[Boolean]]])=>`x$1₄`match{
caseTuple2(state,set)=>
valsetter:Function1[A,F[Boolean]]=((`newValue₃`:A)=>{
val$3$:Tuple2[State,F[Unit]]=(updateAndNotify[Unit](`state₅`,((_$18:A)=>Tuple2.apply[A,Unit](`newValue₃`,()))):@unchecked)match{
caseTuple2(newState,notifyListeners)=>
Tuple2.apply[State,F[Unit]](`newState₂`,`notifyListeners₂`)
}
val`newState₃`:State=$3$._1
val`notifyListeners₃`:F[Unit]=$3$._2
toFlatMapOps[F,Boolean](set.apply(`newState₃`))(F).flatTap[Unit](((succeeded:Boolean)=>catsSyntaxApplicativeByName[F,Unit](`notifyListeners₃`).whenA(succeeded)(F)))
})
Tuple2.apply[A,Function1[A,F[Boolean]]](`state₅`.value,setter)
}))
deftryModifyState[B](`state₆`:cats.data.State[A,B]):F[Option[B]]={
val`f₆`:Function1[A,Eval[Tuple2[A,B]]]=`state₆`.runF.value
$anon.this.tryModify[B](((`a₅`:A)=>`f₆`.apply(`a₅`).value))
}
defmodifyState[B](`state₇`:cats.data.State[A,B]):F[B]={
val`f₇`:Function1[A,Eval[Tuple2[A,B]]]=`state₇`.runF.value
$anon.this.modify[B](((`a₆`:A)=>`f₇`.apply(`a₆`).value))
}
}
(new$anon():SignallingRef[F,A])
}
}))
}" class="documentableName ">of[F[_], A](initial: A)(implicit F: Concurrent[F]): F[SignallingRef[F, A]]
Builds a SignallingRef
for for effect F
, initialized to the supplied value.
Builds a SignallingRef
for for effect F
, initialized to the supplied value.
- Source:
- Signal.scala