get
Method for getting a configured AdService.
This method can be called after configure to obtain AdService. You can simplify it using extensions in your application if your architecture guarantees that AdService is always configured:
fun AdServiceProvider.getOrThrow(): AdService {
return when (val getterResult = get()) {
is AdResult.Success -> getterResult.result
is AdResult.Error -> throw IllegalStateException(
"AdService is not configured: ${getterResult.error.description}"
)
}
}Content copied to clipboard
Return
The result containing the AdService if it has been configured successfully, otherwise an AdError.Configuration error.