getOrNull

fun <T : Any> ServiceLocator.getOrNull(key: ServiceKey<T, *, Unit, *>): T?

Fetches the item for key. If no provider has been registered, returns null. Does not invoke ServiceLocator.onMiss.


inline fun <T : Any> ServiceLocator.getOrNull(): T?

A convenience extension to fetch a singleton instance from the ServiceLocator using its reified type T as the key.

This is equivalent to calling getOrNull(classKey<T>()). If no provider has been registered for T, this will return null and will not invoke onMiss.

Receiver

The ServiceLocator to retrieve the service from.

Return

The singleton instance of type T, or null if not found.