Kotlin Coroutine Jobs (Beginner Example)

แชร์
ฝัง
  • เผยแพร่เมื่อ 31 ม.ค. 2025

ความคิดเห็น • 167

  • @palaksdarji
    @palaksdarji 4 ปีที่แล้ว +11

    You have a unique ability to make things really clear in simplest way possible, Sir! Thank you.

  • @jaserq
    @jaserq 5 ปีที่แล้ว +8

    Whenever I watch any subject from you I am learning it at that moment .. clear and perfect.

  • @sergio3528
    @sergio3528 5 ปีที่แล้ว +24

    Great content, thanks for the awesome stuff.
    However i think there is a mistake in this video...
    At 18:48 you mention that scope.cancel() would cancel any coroutine running in the IO Dispatcher.
    I think this is not the case, scope.cancel() will cancel the coroutines running within that scope (the one created with the first launch() and any other you might have created within that scope), but not the coroutine created in the second scope... that´s a different scope.
    The only way that would be truth would be if you create your second scope like this:
    CoroutineScope(IO + scope) [´scope´ here is the name of the variable in your example]
    In that case, you are kind of bridging together both scopes, so cancelling the first one cancels the second as well (or should i say, the first and second scope are connected as they share the same job).
    In fact... this would happen even if both scopes run in two different threads (let´s say IO and Main).
    So, the moral of the story i guess is that all coroutines created under the same job are glued together and can be cancelled together, regardless of the scope and/or the thread they run on.
    But if they don´t share the same job, cancelling one won´t cancel the other.
    If you think i´m wrong please let me know, we are all learning here :)
    Thanks again for your videos!

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว +6

      Yes I meant the coroutines created in the scope that exclusively references the IO dispatcher. No you're not wrong. You said exactly what I was trying to say.

    • @codetorahul6426
      @codetorahul6426 4 ปีที่แล้ว +1

      Agreed Sergio.. i too tried the same and found what you mentioned... Mitch your videos are awesome.. I always prefer your videos to learn...

    • @misterjedu
      @misterjedu 3 ปีที่แล้ว +2

      Thanks for this. I also created to Jobs using the IO, and one did not cancel the other. I thought I made a mistake somewhere.

  • @baijusharma6027
    @baijusharma6027 5 ปีที่แล้ว +6

    Thank you for sharing your knowledge with us. It will great if you add unit testing in the some of the modules.

  • @sudhir1274
    @sudhir1274 4 ปีที่แล้ว

    Wow. Another very useful tutorial. My understanding of coroutines is getting better and better thanks to your tutorials. I do not watch other videos which in comparison do not help explain coroutines and the code shown is very difficult to implement in practice. Thank you for creating these videos and for the effort put in to explain this concept to new users of coroutines.

  • @ranjanaashish
    @ranjanaashish ปีที่แล้ว

    I continue to be impressed as I keep watching the video from this series 😅. So much helpful

  • @sonamyadav0333
    @sonamyadav0333 5 ปีที่แล้ว +1

    Thank you for sharing your knowledge on Coroutines. Your logical explanations makes things easier to understand. Appreciate your efforts to make things easier to understand through your very logical and practical examples.
    It would be great to have a course on kotlin, if you plan to do any.

  • @therealmujtaba
    @therealmujtaba 5 ปีที่แล้ว +10

    Thank you for the detailed explanation.

  • @n-o-i-d
    @n-o-i-d 5 ปีที่แล้ว

    Great videos, Mitch! 👍
    Just a side note, at 7:23, it will throw a UninitializedPropertyAccessException instead of a NullPointerException, since lateinit variables cannot be a of a nullable type.
    Nothing too serious, just worth mentioning to avoid confusion.

  • @b.k4142
    @b.k4142 5 ปีที่แล้ว +2

    Great you got 50 K flower this week ! when city got 50K people this size is one things can make city to develop itself, i saw in speech for one ceo of compagny who s building city from strach for 2 million people !!

  • @blueheartorangeheart3768
    @blueheartorangeheart3768 5 ปีที่แล้ว +1

    Great video, thanks! One quick note: you sometimes assumed the progress_start val would be zero without explicitly referencing it :P

  • @bekjanomirzak224
    @bekjanomirzak224 3 ปีที่แล้ว +1

    Hello, your tutorials are awesome, please include some challenges which makes your course even better.:)

  • @vundigalarohit8654
    @vundigalarohit8654 4 ปีที่แล้ว

    Hey mitch
    You explain very well !!
    Thanx a ton
    I think u r pretty underrated you should have way more subs

  • @thanosfisherman
    @thanosfisherman 5 ปีที่แล้ว +9

    But how come you are allowed to update the progressbar ( this@startJobOrCancel.progress = i ) on an IO thread and not the Main thread?

    • @DharaniPathyRamalingam
      @DharaniPathyRamalingam 4 ปีที่แล้ว +1

      I have the same doubt!!! @CodingwithMitch should reply to this.

    • @md.rafiqulhasan2319
      @md.rafiqulhasan2319 3 ปีที่แล้ว

      ProgressBar has logic that allows setProgress() to be called on a background thread. It checks to see what thread you are on and does its own post() of a Runnable if needed.

  • @charuwaka1
    @charuwaka1 5 ปีที่แล้ว

    Thanks for explaining minute things also . which is very rare to find in others videos

  • @VishalSingh-eb4zc
    @VishalSingh-eb4zc 5 ปีที่แล้ว +3

    Thank you so much for sharing knowledge brother you are my best favourite youtuber😊😊😊😊😊👍

  • @abhishekpant4927
    @abhishekpant4927 3 ปีที่แล้ว

    Thank you Mitch for all of your effort.

  • @codinginflow
    @codinginflow 5 ปีที่แล้ว +14

    I can see you're trying your hands on the Flow Zoom™

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว +3

      I'm just zooming every which way

    • @croptv7093
      @croptv7093 5 ปีที่แล้ว +1

      when you will post coroutine video? i'm your subscriber too

    • @charuwaka1
      @charuwaka1 5 ปีที่แล้ว

      @@codingwithmitch you both guys rock

    • @charuwaka1
      @charuwaka1 5 ปีที่แล้ว

      @@codingwithmitch which one should i use Dagger or Koin , please explain scenarios

  • @omgpuppet
    @omgpuppet 5 ปีที่แล้ว +13

    17:28 was my breakthrough moment.

    • @happy_gnom
      @happy_gnom 5 ปีที่แล้ว

      Agreed! I also rounded my eyes and had a gasp when I saw that piece of pure magic

    • @jatinvashisht4293
      @jatinvashisht4293 3 ปีที่แล้ว

      Same

  • @erictsang0
    @erictsang0 5 ปีที่แล้ว +1

    Thank you for breaking it all down so simply!!

  • @VenewebTV
    @VenewebTV 2 ปีที่แล้ว

    Excellent video, I learned a lot, regards from Caracas, Venezuela

  • @vinit.
    @vinit. 4 ปีที่แล้ว +4

    Hi Mitch...I have a small doubt...
    In the ProgressBar extension function, inside the Coroutine scope, you are updating the progress bar using delay inside the for loop.
    But this progress bar is the part of the main thread and you are updating it from coroutine IO thread.
    How this is possible?
    We already show the toast you are launching from the main thread using GlobalScope, Dispatchers.Main.

    • @vyn_vyn_vyn
      @vyn_vyn_vyn 4 ปีที่แล้ว

      i think because of .setProgress function in ProgressBar is synchronized

    • @bjugdbjk
      @bjugdbjk 4 ปีที่แล้ว

      I guess, extension function "startJoborCancel" is helping to switch the context to reach the progress bar from the IO thread

  • @buzzminkyunghoon3856
    @buzzminkyunghoon3856 5 ปีที่แล้ว +2

    Video editing is great.

  • @abakasha301
    @abakasha301 4 ปีที่แล้ว +1

    Thank you Mitch, that was really helpful.

  • @cute_hamsterrr
    @cute_hamsterrr ปีที่แล้ว

    Thank you! Your explanation is amazing 😍

  • @royabhriya
    @royabhriya 4 ปีที่แล้ว

    CompleteExceptionally sounds like something that would complete in a very good manner

  • @leoortiz7
    @leoortiz7 5 ปีที่แล้ว +3

    Great tutorial and explanation.

  • @emmanuelonwumah915
    @emmanuelonwumah915 5 ปีที่แล้ว +1

    Hey great video. Could you start writing this kind functionality via view model? It would really depict how to use the architecture component effectively.

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว

      In my new course I'll show you the big picture with real examples

  • @TutorialExprezZ
    @TutorialExprezZ 3 ปีที่แล้ว

    Hi Mitch, thanks a lot for your videos!
    One quick question:
    Why are you not calling job.complete() when the job is finished, and handling the successful job results along with the failure results in the job.invokeOnCompletion interface?
    So when the it : Throwable is not null, that means the job was completed succesfully, and then display the message in the main thread.
    When it's not null then handle the exception.
    Just trying to learn the most correct way to implement it.
    Thanks again for all the effort you put on your videos, means a lot to a bunch of us!!
    Keep safe

  • @vanchikt
    @vanchikt 2 ปีที่แล้ว

    Quality packed explaination

  • @muhammadnaufalfadhillah1223
    @muhammadnaufalfadhillah1223 5 ปีที่แล้ว +3

    Is there any video about endless scroll with recycle view + viewmodel + retrofit + Coroutine?

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว +1

      I don't have one yet. It'll be in my new course.

  • @UKHYUN2378
    @UKHYUN2378 4 ปีที่แล้ว

    Thanks for great video!

  • @euleramon
    @euleramon 3 ปีที่แล้ว

    @13:01 it?.message.let should be changed to it?.message?.let, otherwise, it:String? gets null if throwable? is null, which implies the job is completed successfully rather than "Unknown cancellation error".

  • @rahulrawat329
    @rahulrawat329 5 ปีที่แล้ว +2

    Hey minch!! I have a doubt i think this@startJobOrCancel.progress=i is something that we are doing on main thread..but here you are calling it through background thread... Can you please clarify this think

    • @4sky
      @4sky 5 ปีที่แล้ว +1

      I noticed that as well..

  • @tomislavemilov2247
    @tomislavemilov2247 4 ปีที่แล้ว

    I love your videos

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว

      They are the same. Rxjava just has more operators. And coroutines are easier to read and use with less syntax

  • @rashedulhasan5372
    @rashedulhasan5372 5 ปีที่แล้ว +1

    Nice tutorial. But a bit confused with the double colon used inside button ClickListener > if(!::job.isInitialized).
    why cant I just call job.isInitialized or what is the purpose of using the double colon.Also how to use it?

    • @gabriel_export
      @gabriel_export 5 ปีที่แล้ว +1

      This Kotlin syntax creates a member reference of the variable "job". The verbose syntax would be "this::job.isInitialized" but since he's in the activity when he does this, "this" keyword is not needed. The reason he has to use it in this case is due to the fact that job is a lateinit variable meaning it may have not been initialized at that point meaning there would not be a member reference that you can check yet which is why you have to use that syntax. Hope that makes sense.

  • @gelinkpen93
    @gelinkpen93 3 ปีที่แล้ว

    Thank you so much for the very helpful guide

  • @f-society9704
    @f-society9704 5 ปีที่แล้ว +6

    it is possible to update progress from background thread ??

    • @akhilpandey
      @akhilpandey 4 ปีที่แล้ว +1

      No, to update UI you have to be on UI thread!

    • @bjugdbjk
      @bjugdbjk 4 ปีที่แล้ว

      it's possible in kotlin, If u saw in this example, using the extension function of the progress bar able to access the context of main from IO

  • @mahdizareei4575
    @mahdizareei4575 4 ปีที่แล้ว +1

    excuse me why you didn't use CoroutineScope(Main) or withContext(Main) instead of globalScope(Main)?

  • @bjugdbjk
    @bjugdbjk 4 ปีที่แล้ว

    Mitch, One question @ 18:48, Scope.cancel() you said all the jobs will get cancel on IO, I don't think it's like that, because the scope it's not been tied to the next coroutine scope you created, please correct me if I am wrong, And therefore is there any way to cancel all the coroutines running in IO or any other context directly?

  • @HabeshaDeveloper
    @HabeshaDeveloper 5 ปีที่แล้ว +1

    hey mitch i love all about your videos explanations and i would like to ask you something its not about kotlin .... i want to make Qr code scanner and qr code that changes through time like when each users scan the qr code shows different value and i want to check that value from server .... its like i want to makes games that have qr codes and when users scan they get either empty or some price i hope you understand it please help me thanks

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว

      I think firebase ML toolkit has a we scanner thingy

    • @HabeshaDeveloper
      @HabeshaDeveloper 5 ปีที่แล้ว

      @@codingwithmitch yeah i made qr scanner app with firebase ML but what i need is make the qr codes change for each users

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว +1

      @@HabeshaDeveloper Oh so you need to generate QR codes? Never done that and not sure how it's done

    • @HabeshaDeveloper
      @HabeshaDeveloper 5 ปีที่แล้ว

      @@codingwithmitch owky thanks very much

  • @facile-tech
    @facile-tech 5 ปีที่แล้ว

    I am excited about the new course. Can I subscribe to get the news when it is released ??

  • @pythongabi
    @pythongabi 4 ปีที่แล้ว +1

    Hi, I have a question.
    In the for loop in that extension function startJobOrCancel(), by writing:
    this@startJobOrCancel.progress = i
    we are just updating the UI which is a thing that we should do only if we are in the MAIN thread/scope. But aren't we setting the progress bar in the Coroutine scope and shouldn't that be executed in the MAIN scope, just as like the setText() function. I am a bit confused. How the UI didn't crash. Can you explain this, please?

  • @ahmadbanikamali6936
    @ahmadbanikamali6936 3 ปีที่แล้ว

    hello thanks for your explanations about coroutines.
    my question is how it is possible to update the progress bar value from io thread? (i mean in the for loop section in moment 21:04) and why you did not switch context to main thread to update progress bar value?

  • @ostaprevako8389
    @ostaprevako8389 4 ปีที่แล้ว

    Well, I love the content on this channel, this video is good, but a bit messy. That's the only reason I wrote these highlights.
    At 18:19 is a mistake. I would say the big one.
    The proper code should be like this:
    ```
    val newContext = IO + job
    val job1 = CoroutineScope(newContext).launch { JOB_1 }
    val job2 = CoroutineScope(newContext).launch { JOB_2 }
    job1.cancel() // Cancels only JOB_1, but JOB_2 will be executed!
    newContext.cancel() // Cancels both jobs.
    ```
    What I wish to say is CoroutineScope(coroutineContext).launch returns isolated Job, not the scope. Still, a nice thing was described - you can add job to the context and create a new context.

  • @ShethMilan
    @ShethMilan 4 ปีที่แล้ว

    Very informational about kotlin job coroutines.

  • @rahulmatte6621
    @rahulmatte6621 4 ปีที่แล้ว

    Nice tutorial very informative I got few questions 1 . Is GlobalScope recommended to use since it is easy to use but quite expensive compared to launching Coroutines on Dispatchers.Main for UI operations
    2 . For single Job is very nice to just add job in scope and cancel it any moment with that reference . What of there are chained job say job3 depend on job2 o/p and job2 on job1 o/p recursively. Would you please provide or share your knowledge on How to manipulate the chained job
    Once again thank you for the video I am gonna subscribe it to get notified whenever you post sone new video....cool stufff

  • @bobek3910
    @bobek3910 5 ปีที่แล้ว

    Hi Mitch, should you update the progressbar inside the job scope? I think the better approach would be to update the progressbar also on the global main scope. What would happen if you finish the activity (view) when the job is still running?

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว

      It's just a demo. You can update the progress bar however you want.
      As for the activity question, in onDestroy you could cancel any jobs

  • @jaydonga891
    @jaydonga891 5 ปีที่แล้ว

    great work keep it up.

  • @ratnakarjha7716
    @ratnakarjha7716 4 ปีที่แล้ว

    Awesome Video

  • @dragonzhao433
    @dragonzhao433 ปีที่แล้ว

    why we not simply use withTimeoutOrNull method like u did from previous lesson

  • @Zaki-Was-Here
    @Zaki-Was-Here 4 ปีที่แล้ว

    awesome explaining

  • @deepakborade4123
    @deepakborade4123 4 ปีที่แล้ว +1

    awesome bro.

  • @Jkmsyytttllmhgccf
    @Jkmsyytttllmhgccf 5 ปีที่แล้ว +1

    at 9.05 use msg -> isntead of val msg = it :)

  • @ChrisAthanas
    @ChrisAthanas 3 ปีที่แล้ว

    Great tutorial

  • @hiteshbhalala7341
    @hiteshbhalala7341 4 ปีที่แล้ว +1

    How progress bar geeting updated in IO thread?

  • @slayer5171
    @slayer5171 4 ปีที่แล้ว

    Hai Mitch, thank you for the video. I learn alot, but I still have question in previous video you say that function need to use suspend extension.
    Why updateJobCompleteTextView still can be called from coroutine scope even it doesn't use suspend keyword? Thanks for answer

    • @codingwithmitch
      @codingwithmitch  4 ปีที่แล้ว +1

      Non-suspend functions can be called within a coroutine. That doesn't matter. But suspend functions must be called within coroutines or other suspend functions

  • @MrDV44
    @MrDV44 4 ปีที่แล้ว

    using UI state (e.g. a value of a ProgressBar) to figure out if a Job (or anything else) is running - is a bad practice. the UI state must depend on logic, not the other way around.

  • @soul-software-survivor
    @soul-software-survivor 4 ปีที่แล้ว

    If you wanted to update the progress bar on the main thread from within that coroutine, how would you do it? It's probably not a good idea to update it on a worker thread.

  • @Ilamarea
    @Ilamarea 2 ปีที่แล้ว

    I've got a couple questions.
    Is there any benefit to passing a job as a parameter, when coroutines create their own? Is that a parent job, coupling children jobs together for group cancellation as an example, or is it the job that the coroutine returns?
    Would it be necessary to cancel the job in onDestroy if it was run in lifecycleScope instead of GlobalScope/CoroutineScope?
    Wouldn't it be better to use withContext(){} to change the dispatcher to main, to change the UI text rather than a separate function with GlobalScope?

  • @mohamedmedhat5149
    @mohamedmedhat5149 3 ปีที่แล้ว

    18:10 Hi Dude, I have tried creating two different coroutines that run on the IO scope and stopped one of them and the other one continued normally. Am I missing something?

  • @safionweb
    @safionweb 3 ปีที่แล้ว

    Rather than coding for the first 30 minutes and then showing output, in the end, It would be better if you show the output alongside.

  • @brianroberts5958
    @brianroberts5958 3 ปีที่แล้ว

    Creating the CoroutineScope with (IO + job) is not necessary here, right? You never cancel the coroutine scope itself, only the job.
    If you cancelled the coroutine scope itself, sure... But to me it looks like you are only cancelling the job which _happens_ to be scheduled on _a_ coroutine scope, but cancelling this job would not affect whatever coroutine scope it is scheduled on, right? And therefore it would not cancel other coroutines scheduled on said Coroutine scope.

  • @dork3nergy
    @dork3nergy 4 ปีที่แล้ว

    I'm curious as to why you passed 'job' to startJobOrCancel. Isn't it a global or top level (whatever it's called) variable?

  • @apoorvgupta2511
    @apoorvgupta2511 4 ปีที่แล้ว

    InvokeOnCompletion seems to have similarities with setOnCompleteListener
    Is it?

  • @swatiarya4889
    @swatiarya4889 3 ปีที่แล้ว

    Hi sir this is quite interesting but the. Just wanted to ask could you please help me with the stable version I am android developer having an experience of 4 years ... I am facing an issues in artic fox ...

  • @millionwaldeab9584
    @millionwaldeab9584 4 ปีที่แล้ว

    You are creating a new job instance but expect the error message from your exception attached to your old instance is passed when you reset the progress? I am confused about that. Can you clarify that please?

  • @stefanusanggara1268
    @stefanusanggara1268 4 ปีที่แล้ว

    thanks for good video. but why do we cancel the Job if it's already completed? is that mandatory to cancel completed job?

    • @stefanusanggara1268
      @stefanusanggara1268 4 ปีที่แล้ว

      or the essence about cancel the job is making it reusable? because job.cancel and initJob() are wrapped into same method.

  • @ferdihaspin5069
    @ferdihaspin5069 5 ปีที่แล้ว

    Hatur nuhun mang 🙏

  • @cryptobrewery1511
    @cryptobrewery1511 5 ปีที่แล้ว

    Thanks for this amazing tutorial, but I'm wondering what's preventing here the memory leak?, like if the View is destroyed and the coroutine is still working shouldn't we stop it to remove the reference to textView ?

  • @mohammadmujahid8850
    @mohammadmujahid8850 4 ปีที่แล้ว

    Thannk u Mitch.

  • @gabgonzales7359
    @gabgonzales7359 4 ปีที่แล้ว

    This has been asked a number of times now but I don't think it's been answered or explained yet, but how do you update ProgressBar.progress in a IO context coroutinescope? I first thought that it would have caused the app to crash or you will have caught it along the way and perhaps change the coroutine context to Main or UI for the ProgressBar update but you didn't and for some reason the app still ran, still confused about this. Thanks.

  • @amartyaganguly4876
    @amartyaganguly4876 5 ปีที่แล้ว

    So GlobalScope(Main) and withContext(Main) basically achieve the same thing? What is the difference between them and when to use which one?

  • @kgandkg
    @kgandkg 4 ปีที่แล้ว

    Such great content but seriously what’s with the font!

  • @vaisakhn104
    @vaisakhn104 4 ปีที่แล้ว

    You are updating the progress on IO scope

  • @bekjanomirzak224
    @bekjanomirzak224 3 ปีที่แล้ว

    I didn't understand this part of code. How is it possible to update the UI with IO context? I am referring to the progressBar. Could you explain?
    CoroutineScope(IO+job).launch {
    println("coroutine ${this} is activated with job $job")
    for(i in PROGRESS_START.. PROGRESS_MAX){
    delay((JOB_TIME/PROGRESS_MAX).toLong())
    this@startJobOrCancel.progress=i

  • @is0658
    @is0658 5 ปีที่แล้ว

    hi Mitch, do you use coroutines for data streaming or you still choose rxjava?

  • @neerajsewani5764
    @neerajsewani5764 5 ปีที่แล้ว

    I can see GrpahQL written on the board in the background. Any plans on ditching the REST API and using GraphQL with Android?

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว +1

      Ya I want to do something with it

    • @neerajsewani5764
      @neerajsewani5764 5 ปีที่แล้ว

      @@codingwithmitch I have been learning it for quite a time now and mostly people are using it in web. It would be great to have tutorials on GraphQL with Android from you.

  • @anshsachdeva850
    @anshsachdeva850 3 ปีที่แล้ว

    hey mitch, i tried a thing. on a press of a button, i just initialise a global job variable if its null. otherwise log its isComplete, isActive and isCancelled variable. everytime a job is created , the isActive starts sending true. but i haven't started any coroutine using that job .
    so is it correct to assume that if (job is not completed) then job can be either running in a coroutine or yet to start a coroutine otherwise job has finished?
    I just don't like using the state of progressbar as a toggle for starting/stoping an api request. i want to be able to do that using the concurrency layer itself. so if (job.iscompleted==false) we start our job , not when job.isActive==true , right?

  • @shahzebmushtaq1297
    @shahzebmushtaq1297 5 ปีที่แล้ว

    great stuff really useful
    but not use the suspend keyword when using coroutine i didnot get it

  • @githaramm8274
    @githaramm8274 3 ปีที่แล้ว

    @CodingWithMitch
    Firstly a big thanks for your videos, they are very much informative and helpful to understand better.
    In this video, you are trying to update progress value (this@startJobOrCancel.progress=i) on a worker thread CoroutineScope(IO), can you please brief about this?

  • @simonhamour1454
    @simonhamour1454 2 ปีที่แล้ว

    i don't have dataBinding, how can i turn on that feature on Android Studio Chipmunk?

  • @naufalfadhil3479
    @naufalfadhil3479 4 ปีที่แล้ว

    what is difference between globalscope vs coroutinescope ?

  • @ameenmaheen
    @ameenmaheen 5 ปีที่แล้ว

    Hey Mitch. What happens when job is running and activity no longer exists ?? Any suggestions ?

    • @rahulrawat329
      @rahulrawat329 5 ปีที่แล้ว

      You can cancel that particular job while depending on while you're navigating to another activity aur minimise your application.

  • @ofir-bar-softr
    @ofir-bar-softr 5 ปีที่แล้ว

    Hi, why do we do the "IO + job" number?
    I mean, why don't we just do "job" as a Context?

    • @ahmadbanikamali6936
      @ahmadbanikamali6936 3 ปีที่แล้ว

      beacouse in the CoroutinContext class we have operator plus method witch refres to + sign. if you ctrl click the plus sign in this expression then plus method shown to you.

  • @AhsanAli-vz6mg
    @AhsanAli-vz6mg 4 ปีที่แล้ว

    Superb

  • @fabrizioalmeida8435
    @fabrizioalmeida8435 5 ปีที่แล้ว

    Hey Mitch how are you? Man I work on a project that no have completable job, only job, is there any way I substitute job.complete(), I put job.iscomplet but I not Shure is correct, I can't update library, please help me :)

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว

      Then change it to a Completable job?

  • @gabormiklay9209
    @gabormiklay9209 5 ปีที่แล้ว

    i'm really coriuos about the powerful android apps with jetpack architecture course. so, i'd like you to do that first.
    thx.

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว +1

      Yep I'm working on it. Just doing these in between

  • @Punarjagran
    @Punarjagran 3 ปีที่แล้ว

    IO+job ~> allowing Progress bar ui update? 🤯

  • @legendinisZ
    @legendinisZ 4 ปีที่แล้ว

    woah, wanted to learn about coroutines, guy makes extension function to check if job is in progress by checking progress bar progress. paused video, left a comment, closed tab. What a terrible responsibility error. I'll keep on looking for another tutorial.

  • @facile-tech
    @facile-tech 5 ปีที่แล้ว

    Will you add testing to the new course ???

    • @codingwithmitch
      @codingwithmitch  5 ปีที่แล้ว +2

      Prob not. It's going to be massive already. When it's done I'll do a UI testing course with espresso

    • @facile-tech
      @facile-tech 5 ปีที่แล้ว

      Excited! More than espresso it would be great to see how to test code with coroutine and use Dagger 2 in Kotlin

  • @fuadreza3090
    @fuadreza3090 4 ปีที่แล้ว

    Nicely done.. (y)

  • @pawemuniak634
    @pawemuniak634 4 ปีที่แล้ว +1

    var msg = it?.message ?: "Unknown cancellation reason.."

    • @bro_chenzox
      @bro_chenzox 4 ปีที่แล้ว

      @
      Paweł Muniak yeap, instead of 4-5 lines for one null check.
      val msg = it?.message ?: "Unknown cancellation error."

  • @faustofl
    @faustofl 5 ปีที่แล้ว

    Cool!

  • @bjornk.567
    @bjornk.567 4 ปีที่แล้ว

    Actually it is totally wrong that you cancel the IO scope when creating a scope from IO and cancel THAT scope, you should fix this in your video!

  • @blackhawk3855
    @blackhawk3855 4 ปีที่แล้ว

    why dont you try in acting, I mean in hollywood something

  • @gabormiklay9209
    @gabormiklay9209 5 ปีที่แล้ว

    kotlin prefers property access.
    job_button.text = "Start Job #1"

  • @jatinvashisht4293
    @jatinvashisht4293 3 ปีที่แล้ว +1

    28:49

  • @HeinerTheBest
    @HeinerTheBest 5 ปีที่แล้ว

    I was follow the code step by step but I got a Crash
    java.lang.IllegalStateException: Module with the Main dispatcher is missing. Add dependency providing the Main dispatcher, e.g. 'kotlinx-coroutines-android'
    but I fixed with this
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.0.1'
    implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1'
    I don't know if someone maybe will need it
    Thanks for the Video Mitch was awesome (Y)

  • @vasilemoraru89
    @vasilemoraru89 4 ปีที่แล้ว +1

    i try to compile it now an get
    java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button.setText(java.lang.CharSequence)' on a null object reference
    at com.example.myapplication.MainActivity.startJobOrCancel(MainActivity.kt:69)
    at com.example.myapplication.MainActivity$onCreate$1.onClick(MainActivity.kt:33)

    • @sooshil
      @sooshil 4 ปีที่แล้ว

      @CodingWithMitch
      I too have same problem. If I comment out that line, it works fine. When I try to set text for the button, it crashes throwing NPE.