SHARE
TWEET

Untitled

a guest Oct 21st, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. fun main() {
  2.  
  3.     Database().load("https://jsonplaceholder.typicode.com/users/1", object : Callback {
  4.         override fun onLoadData(result: String) {
  5.             println(result)
  6.         }
  7.     })
  8. }
  9.  
  10.  
  11. /*
  12. *  Callback using via interface
  13. * */
  14. interface Callback{
  15.     fun onLoadData(result: String)
  16. }
  17.  
  18. class Database {
  19.     fun load(link: String, callback: Callback) {
  20.         val result = RequestHelper.getData(link)
  21.         callback.onLoadData(result)
  22.     }
  23. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top