Kotin Class
class LoginService{
fun getLoginData(loginData: String) {
request(LoginApi.create().getLoginData(loginData))}
}
fun changePassword(_:String){
request(LoginApi.create().changePassword(_)
}
class RequestData {
var retrofitCall: ((String) -> Unit)? = null
}
}
Java Class
class LoginModel{
private void loginData(){
RequestData data = new RequestData();
requestData.setRetrofitCall(username ->LoginService::getLoginData)
}
private void changePassword(){
RequestData data = new RequestData();
requestData.setRetrofitCall(username ->LoginService::changePassword)
}
}
requestData.setRetrofitCall(username ->LoginService::changePassword)
Why Higher order function :
Since i have to differentiate between each API call for calling a function from its feature hence trying to use.
How to call the above highlighted code?
Using Kotlin Functional Interfaces in Java is a little tricky and not very clean.
Your
setRetrofitCall()would need to look something like this: