SecureAreaProvider

class SecureAreaProvider<out T : SecureArea>(context: CoroutineContext = Dispatchers.Main, provider: suspend CoroutineScope.() -> T)

Lazily creates a SecureArea.

SecureArea creation is typically asynchronous and cannot be completed in a synchronous scopes (such as at static initialization or callbacks like onCreate). This class provides a wrapper to hold an asynchronously-created SecureArea. To create a SecureArea in synchronous context, use

// synchronous initialization code
val fooSecureAreaProvider = SecureAreaProvider { FooSecureArea.create(storage, ...) }

Then when using secure area in an asynchronous context (which is required as SecureArea APIs are asynchronous):

// asynchronous code
val fooSecureArea = fooSecureAreaProvider.get()
fooSecureArea.someApiCall()

Constructors

Link copied to clipboard
constructor(context: CoroutineContext = Dispatchers.Main, provider: suspend CoroutineScope.() -> T)

Functions

Link copied to clipboard
suspend fun get(): T