japgolly.scalagraal.util
Type members
Classlikes
Caches A => F[String]
functions and makes them super-fast by executing once per path,
optimising and caching the result, and then using it as template for all subsequent calls.
Caches A => F[String]
functions and makes them super-fast by executing once per path,
optimising and caching the result, and then using it as template for all subsequent calls.
"Paths" are independent from each other and are defined by StrFnCacheParam instances. There is typically
one path per sum type, for example Option
has two paths: None
and Some[A]
; String
only has one which is
itself.
Values (once in a path) must be completely opaque and not used to affect function logic or conditionality. For example, a function that takes a name and prints it a few times is fine, but a function which branched according to string length, or converted the string to uppercase would be broken by this cache because the caching logic doesn't branch according to string length, and the caching logic doesn't convert strings to uppercase. You can still have your super-fast cake and eat it too by creating your own customised StrFnCacheParam instance that includes any value modification or branching you need. In such cases it would be wise to cross-compile the logic rather than duplicate it, and/or modify your function (or React component) to accept inputs that have already been processed.
- Since
1.1.0
A specific subset of a type that will be cached.
A specific subset of a type that will be cached.
For example, you would have a StrFnCachePath[Option[A]]
for the None
case,
and another StrFnCachePath[Option[A]]
for the Some
case.
- Value Params
- isApplicable
Whether a given value of
A
is within the subset ofA
represented by this path/instance.
- Companion
- object
Deprecated classlikes
Takes a potentially slow String* => String
function and makes it super fast by executing it once,
optimising and caching the result, and then using it as template for all subsequent calls.
Takes a potentially slow String* => String
function and makes it super fast by executing it once,
optimising and caching the result, and then using it as template for all subsequent calls.
This assumes provided functions are pure (e.g. embedding the current time would be a violation).
This assumes provided functions treat their inputs as opaque values (e.g. inspecting an argument representing a username to provide "john" a different result than "mary" is a violation.)
Note: If you call compileN with a function that returns an japgolly.scalagraal.Expr and see an error about an implicit Functor not found, add this import:
import cats.instances.either._
- Deprecated