API reference
API reference
Select your platform
No SDKs available
No versions available

HorizonServiceConnection Class

Modifiers: final
Service connection class responsible for delegating requests over platform layers. This class is single-instance and must be initialized with HorizonServiceConnection.Companion.connect and accessed via HorizonServiceConnection.Companion.instance. An instance can immediately be used any time after calling HorizonServiceConnection.Companion.connect but the first requests may delay until initialization is complete to execute.

Signature

class HorizonServiceConnection

Companion Object

Companion Object Properties

instance : HorizonServiceConnection
[Get]
Acquire a reference to the Horizon Platform instance, which can be used to make raw requests and sessions. You probably shouldn't ever need to use this.
Signature
val instance: HorizonServiceConnection

Companion Object Functions

connect ( applicationId , context , scope , config )
Initialize the Horizon Platform. This method must be called before any other service methods can be executed.
The lifecycle of this connection is determined by the HorizonServiceConnection.Companion.connect passed into this method. Prefer scopes which do not terminate on background, as several common features require your app to move to the background in order to function.
Activity-scoped Lifecycle:
// MainActivity.kt onCreate
HorizonServiceConnection.connect(APPLICATION_ID, context, lifecycleScope)

ViewModel-scoped Lifecycle:
class MyViewModel: ViewModel() {
  init {
    HorizonServiceConnection.connect(APPLICATION_ID, context, viewModelScope)
  }
}

Signature
fun connect(applicationId: String, context: Context, scope: CoroutineScope), config: HorizonPlatformConfig = HorizonPlatformConfig())
Parameters
applicationId: String
The application id to use for the connection
context: Context
The Android context
scope: CoroutineScope
The CoroutineScope that defines the lifespan of the connection. Defaults to a never ending lifespan
config: HorizonPlatformConfig
Optional configuration data to give the user more control over execution where possible

Inner Class

InitializationStage Class

Inner Objects

Inner Class

InitializationFailed Class

Extends HorizonServiceConnection.InitializationStage
Modifiers: final

Signature

data class InitializationFailed(val error: Throwable) : HorizonServiceConnection.InitializationStage

Constructors

InitializationFailed ( error )
Signature
constructor(error: Throwable)
Parameters
error: Throwable
Returns
HorizonServiceConnection.InitializationStage.InitializationFailed

Properties

error : Throwable
[Get]
Signature
val error: Throwable

Signature

sealed class InitializationStage