Kotlin Callbacks, Closures & Lambdas

Поділитися
Вставка
  • Опубліковано 15 жов 2024

КОМЕНТАРІ • 23

  • @EALarin41
    @EALarin41 3 роки тому +3

    Thanks man! I couldn't understand it in my native language (Russian). Your explanation made it clear.

  • @agustino.4325
    @agustino.4325 4 роки тому +9

    Having the code (as in a git repo) would be much appreciated, might make it a bit easier to follow! Great video nonetheless!!

    • @kotlinbytes95
      @kotlinbytes95  4 роки тому +4

      That's an excellent idea! I'll do this for newer videos.

  • @lukemartin9977
    @lukemartin9977 2 роки тому +2

    Yup. Still massively confused. I tried pausing it and slowing it down and watching it multiple times. You go REALLY fast. I think one of the things that is so confusing about these things is the fact that there are multiple ways to do them so it seems like every example is a little different adding to the confusion.

  • @smit9779
    @smit9779 Рік тому

    Thank you very much you have explained it very clearly

  • @saharas7635
    @saharas7635 2 роки тому

    Great. Thank you so much🙂

  • @jakhongirmadaminov5849
    @jakhongirmadaminov5849 3 роки тому +1

    Nice and neat explanation 👍

  • @swaminathbera6407
    @swaminathbera6407 Рік тому

    Clean AND Perfect 💝

  • @iftak01
    @iftak01 3 роки тому

    Great vids dude, keep it going

  • @GriNAME
    @GriNAME 3 роки тому

    Thanks man! You really helped me!

  • @ahmad7a.4k28
    @ahmad7a.4k28 2 роки тому

    Thanks a lot! really helped me

  • @ehsanalrawi188
    @ehsanalrawi188 3 роки тому +2

    When you want to explain one idea, try to make the surrounding ideas as simple as possible. Here rather than concentrating on callback we start following that many classes that call each others. Thank you for tutorial.

  • @moonkin340
    @moonkin340 4 роки тому

    Good demonstration, good selection of examples but for someone with Zero Background a little bit too much at once.

  • @anirudhganesh
    @anirudhganesh 4 роки тому

    Really liked the way that you explained. But it would be really cool if you also had a git link for the code. I was stuck with async programming for a month, posted question in stack yet everyone was going for coroutines asking me to suspend a function until it gets a result back? I quite didn't get that either.

    • @kotlinbytes95
      @kotlinbytes95  4 роки тому +1

      I'm glad it helped you! I just uploaded the source code here: github.com/jacobklewis/Scratch-Notes/blob/master/src/main/kotlin/me/jacoblewis/callbacks/Callbacks.kt
      I will likely create a video on coroutines later; in fact, I actually prefer coroutines. However that was outside of the scope for this video.
      Message me if you have more questions!

  • @sim77778777
    @sim77778777 3 роки тому

    How would compatibility between Kotlin and java work for lamba ? For eg , invoke the callback through a kotlin file but it passes down to a java file which ultimately needs to implement this callback

  • @null4961
    @null4961 4 роки тому +1

    How is delay accepting another argument?
    delay(type.brewTime){
    val madeCoffee = Coffee(type)
    callback.onCoffeeBrewed(madeCoffee)
    }
    Why is this not giving error?
    I am trying to fetch API data and show in the TextView. Where do I put the reference to callback function? I am using simple HttpURLConnection and InputStream to fetch the data.

    • @kotlinbytes95
      @kotlinbytes95  4 роки тому

      The delay function here is a custom function to simulate something like a network request. It might be confusing if you're familiar with coroutines because there is a delay function here as well. You could replace this with an async network request. The async network request will likely have it's own type of closure, however this is dependent on the framework used. Are you building something for Android or only the JVM?

    • @null4961
      @null4961 4 роки тому

      @@kotlinbytes95 i am building for android. can you provide the source code you showed in the video? I dont know where to put the reference to the callback function.

    • @kotlinbytes95
      @kotlinbytes95  4 роки тому

      Cheenu soni,
      Here is a simple network library that I recently published to GitHub:
      github.com/jacobklewis/Simple-Network
      Look at the README for details on how to use. It utilizes the built in HttpsURLConnection classes that are provided with Android. Feel free to use this code in any way you'd like. Note that HttpsURLConnection is a "blocking" network library (it will make the UI freeze), so it needs to be wrapped in something that will execute it on an IO thread. This library handles that for you.
      Here is the direct library source code:
      github.com/jacobklewis/Simple-Network/tree/master/network/src/main/java/me/jacoblewis/network
      If you are open to other libraries, here are a few other considerations:
      OkHttp: github.com/square/okhttp
      Retrofit: square.github.io/retrofit/

  • @kr0fff
    @kr0fff 2 роки тому

    Not clealry understand by the first time, i think you should initiate classes in one file for clarity

  • @arijithazra573
    @arijithazra573 3 роки тому

    My brain is getting numb