case class MemoizeLast[-T, +R](f: (T) => R, eq: (T, T) => Boolean = (a: T, b: T) => a == b) extends (T) => R with Product with Serializable
Memoize the last value only. Since its only 1 arg, use yourfunc _ tupled
to tuple the arguments. Uses scala == for the test. js semantics for
equality are very different. scala provids semantic equality unlike js. An
optional eq
can be used. In general, you will probably memoize js
functions using the react hooks so may not need this memoization utility
much.
- See also
https://medium.com/musings-on-functional-programming/scala-optimizing-expensive-functions-with-memoization-c05b781ae826
- Alphabetic
- By Inheritance
- MemoizeLast
- Serializable
- Product
- Equals
- Function1
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Instance Constructors
Value Members
- def andThen[A](g: (R) => A): (T) => A
- Definition Classes
- Function1
- Annotations
- @unspecialized()
- def apply(x: T): R
- Definition Classes
- MemoizeLast → Function1
- def compose[A](g: (A) => T): (A) => R
- Definition Classes
- Function1
- Annotations
- @unspecialized()
- val eq: (T, T) => Boolean
- val f: (T) => R
- def hits: Long
- def productElementNames: Iterator[String]
- Definition Classes
- Product
- def toString(): String
- Definition Classes
- Function1 → AnyRef → Any