// SDK 1.16
override var tripStatusCallback: Callback<Status>
tripStatusCallback.execute(Status.from(tdStatus))
Instead of Callback<Status> we will pass a lambda function((Status) -> Unit)
The following is the migrated version of above code to SDK 1.17
// SDK 1.17
override var tripStatusCallback: ((Status) -> Unit)
tripStatusCallback(Status.from(tdStatus))
Basically swap Callback<Status> with a lambda which takes a Status type parameter and returns Unit and remove the .execute call and directly call the lambda.
You could also call the lambda like tripStatusCallback?.invoke(Status.from(tdStatus)) in case if callback is nullable. Below is the example for the same.
// SDK 1.17
// The callback parameter is nullable
override var tripStatusCallback: Callback<Status>? = null
tripStatusCallback?.invoke(Status.from(tdStatus))
Updating ResultCallback interface with a lambda function
Basically swap ResultCallback<String> with a lambda which takes a Result<String> type parameter and returns Unit and remove the .execute call and directly call the lambda.
You could also call the lambda like callback?.invoke(Result.Success(signedToken)) in case if callback is nullable. Below is the example for the same.
// SDK 1.17
// The callback parameter is nullable
override fun sign(unsignedToken: String, callback: ((Result<String>) -> Unit)?) {
val components = unsignedToken.split(".")
if ((components.size != 2) || (privateKey == null)) {
callback?.invoke(Result.Failure(Throwable()))
} else {
val signedToken = Jwts.builder()
.setHeaderParams(decode(components[0]))
.setClaims(decode(components[1]))
.signWith(SignatureAlgorithm.RS256, privateKey)
.compact()
callback?.invoke(Result.Success(signedToken))
}
}
Accessing members from MonitorCallbacks
This only affects you, if you’re inheriting/implementing the MonitorCallbacks interface.
If you are inheriting/implementing the interface MonitorCallbacks , you won't be able to access the following members directly in the child class.