Skip to content

Commit

Permalink
Fixed #631: Added mutable.QuickCache alias
Browse files Browse the repository at this point in the history
  • Loading branch information
davesmith00000 committed Nov 18, 2023
1 parent ece9615 commit e9b3058
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
13 changes: 13 additions & 0 deletions indigo/indigo/src/main/scala/indigo/package.scala
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ object syntax:

end syntax

object mutable:

type CacheKey = shared.CacheKey
val CacheKey: shared.CacheKey.type = shared.CacheKey

type ToCacheKey[A] = shared.ToCacheKey[A]
val ToCacheKey: shared.ToCacheKey.type = shared.ToCacheKey

type QuickCache[A] = shared.QuickCache[A]
val QuickCache: shared.QuickCache.type = shared.QuickCache

end mutable

val logger: indigo.shared.IndigoLogger.type = indigo.shared.IndigoLogger

type Startup[SuccessType] = shared.Startup[SuccessType]
Expand Down
9 changes: 9 additions & 0 deletions indigo/indigo/src/main/scala/indigo/shared/QuickCache.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
package indigo.shared

/** QuickCache is a handy way to avoid expensive re-calculation of data. It is a side-effecting arrangement that Indigo
* uses a lot internally, that can also be used by cautious game devs. Simple example:
```
given QuickCache[MyExpensiveObject] = QuickCache.empty
QuickCache("key")(obj)
```
*/
final class QuickCache[A](private val cache: scalajs.js.Dictionary[A]):

def fetch(key: CacheKey): Option[A] =
Expand Down

0 comments on commit e9b3058

Please sign in to comment.