AppContext

com.github.rssh.appcontext.AppContext
opaque object AppContext

Application context is a way, to resolve components dependencies. Each component should provide an AppContextProvider, and AppContext[Component] will instantiate this components with dependencies.

Attributes

Source
AppContext.scala
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
AppContext.type

Members list

Type members

Types

opaque type Cache

Type for component cache. By convention, if component depends from cache then it's AppContextProvider should check if this component is already in cache and instantiate new (and update cache) only if it's not found.

Type for component cache. By convention, if component depends from cache then it's AppContextProvider should check if this component is already in cache and instantiate new (and update cache) only if it's not found.

Attributes

Source
AppContext.scala
opaque type CacheKey[T]

Type for cache key. By convention, usually this is a type.show.

Type for cache key. By convention, usually this is a type.show.

Attributes

Source
AppContext.scala

Value members

Concrete methods

def apply[T](using AppContextProvider[T]): T

Get component from application context. For this component should have an implicit AppContextProvider.

Get component from application context. For this component should have an implicit AppContextProvider.

Type parameters

T
  • component to instantiate

Attributes

See also

AppContextProvider

Source
AppContext.scala
inline def cacheKey[T]: CacheKey[T]

Attributes

Source
AppContext.scala
def customCacheKey[T](key: String): CacheKey[T]

Attributes

Source
AppContext.scala

Create empty cache.

Create empty cache.

Attributes

Returns

empty cache

Source
AppContext.scala

Extensions

Extensions

extension (c: Cache)
inline def get[T]: Option[T]

Get component from cache.

Get component from cache.

Type parameters

T
  • component type

Attributes

Returns

Some(component) or None if component is not found.

Source
AppContext.scala
inline def getOrCreate[T](value: => T): T

Get component from cache or create new one and update cache.

Get component from cache or create new one and update cache.

Type parameters

T
  • component type

Value parameters

value
  • function to create new component

Attributes

Returns

just created or cached component

Source
AppContext.scala
inline def modify[T](f: (Option[T]) => Option[T]): Unit

Modify component in cache.

Modify component in cache.

Type parameters

T
  • component type

Value parameters

f
  • function to remap

Attributes

Source
AppContext.scala
inline def put[T](value: T): Unit

Put component to cache, replacing old if needed

Put component to cache, replacing old if needed

Attributes

Source
AppContext.scala
inline def remove[T]: Unit

Remove component from cache.

Remove component from cache.

Type parameters

T
  • component type

Attributes

Source
AppContext.scala