diff --git a/README.md b/README.md index a9a38af..9f3bc7d 100644 --- a/README.md +++ b/README.md @@ -41,13 +41,16 @@ Version numbers can be found under [Releases](https://github.com/tidal-music/net ## Usage Create your `SNTPClient` via its constructor. Its API allows you to toggle synchronization (starts -off) and to retrieve the time based on the latest successful synchronization, if any. +off) and to retrieve the time based on the latest successful synchronization. -The property that retrieves the aforementioned time is nullable as it will return `null` if no +The nullable property `epochTime` retrieves the aforementioned time will return `null` if no synchronization has occurred successfully during the lifetime of the process and no backup file has been specified for the `SNTPClient` instance or said file contains no valid prior synchronization data. +As an alternative, the `blockingEpochTime` method can be used to suspend the caller until a valid +synchronization or backup restoration occurs to avoid a nullable return type. + ## networktime-singletons This is a tiny utility on top of the base artifact that extends the `SNTPClient` API by adding a new diff --git a/networktime/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt b/networktime/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt index a849644..9c23b11 100644 --- a/networktime/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt +++ b/networktime/src/commonMain/kotlin/com/tidal/networktime/SNTPClient.kt @@ -39,7 +39,8 @@ class SNTPClient( val epochTime by delegate::epochTime /** - * The calculated epoch time, blocking until it has been calculated at least once. + * The calculated epoch time. Suspends the caller until said time has been calculated at least + * once. */ @ObjCName(name = "blockingEpochTimeMs") suspend fun blockingEpochTime() = delegate.blockingEpochTime()