Px

sealed abstract class Px[A]

A mechanism for caching data with dependencies.

This is basically a performance-focused, lightweight implementation of pull-based FRP, pull-based meaning that in the chain A→B→C, an update to A doesn't affect C until the value of C is requested.

What does Px mean? I don't know, I just needed a name and I liked the way @lihaoyi's Rx type name looked in code. You can consider this "Performance eXtension". If this were Java it'd be named AutoRefreshOnRequestDependentCachedVariable.

Companion:
object
class Object
trait Matchable
class Any
class Derivative[A]
class DerivativeBase[A, B, C]
class FlatMap[A, B]
class Map[A, B]
class Root[A]
class ThunkM[A]
class Var[A]

Value members

Abstract methods

def peek: A

Get the last used value without updating.

Get the last used value without updating.

def rev: Int

Revision of its value. Increments when value changes.

Revision of its value. Increments when value changes.

def value(): A

Get the latest value, updating itself if necessary.

Get the latest value, updating itself if necessary.

Concrete methods

def extract(implicit e: Extract[A]): A

If this Px contains a function, it can be extracted and the Px dropped from the signature. Every time the function is invoked it will use the latest value of this Px, even if you don't explicitly hold a reference to it anymore.

If this Px contains a function, it can be extracted and the Px dropped from the signature. Every time the function is invoked it will use the latest value of this Px, even if you don't explicitly hold a reference to it anymore.

Example. From a Px[Int => String], an Int => String can be extracted.

def flatMap[B](f: A => Px[B]): Derivative[B]
def map[B](f: A => B): Derivative[B]
final def toCallback[F[_]](implicit F: Sync[F]): F[A]
final def valueSince(r: Int): Option[A]