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

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

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

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

inline def cacheKey[T]: CacheKey[T]
def customCacheKey[T](key: String): CacheKey[T]

Create empty cache.

Create empty cache.

Attributes

Returns

empty cache

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.

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

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

inline def put[T](value: T): Option[T]

Put component to cache, replacing old if needed

Put component to cache, replacing old if needed

Attributes

inline def remove[T]: Option[T]

Remove component from cache.

Remove component from cache.

Type parameters

T
  • component type

Attributes