Be VERY Careful with GlobalScope

Поделиться
HTML-код
  • Опубликовано: 25 ноя 2024

Комментарии • 55

  • @andrefilgueiras
    @andrefilgueiras 4 года назад +2

    I was using GlobalScope to send some logs to a server and I saw everybody saying not to use it. Now I know that I was right because this is the perfect example to use it. Thanks Mitch, just like you said, GlobalScope is for analytics.

  • @codinginflow
    @codinginflow 4 года назад +24

    wow!

    • @nicolucian6604
      @nicolucian6604 3 года назад

      you prolly dont give a shit but does anybody know of a way to get back into an Instagram account??
      I stupidly lost the login password. I love any tips you can give me.

    • @onyxshepard5057
      @onyxshepard5057 3 года назад

      @Nico Lucian instablaster =)

    • @nicolucian6604
      @nicolucian6604 3 года назад

      @Onyx Shepard Thanks so much for your reply. I found the site through google and I'm in the hacking process now.
      Seems to take a while so I will get back to you later with my results.

  • @BelokonRoman
    @BelokonRoman 4 года назад +13

    Hi,
    the problem you show in the video is not the problem of the GlobalScope. It is the problem of breaking "structured concurrency". If you replace GlobalScope with any another scope(for instance you can write CoroutineScope(Main).launch instead of GlobalScope.launch) - you will have the same issue. This is because you launch new coroutines on the other scope and break parent-child relation

  • @GakisStylianos
    @GakisStylianos 4 года назад +12

    You're not my dad. I do what I want 🤣

  • @BRUHItsABunny
    @BRUHItsABunny 4 года назад +1

    thanks for the demonstration, I wasn't able to find much on this subject a few month ago
    i guess i will refactor GlobalScope out of my code where needed soon

  • @gamiike
    @gamiike 2 года назад

    Thank you Mitch,
    I was just struggling from handling GlobalScope!
    Best Regard from Japan

  • @bahaaka828
    @bahaaka828 4 года назад

    the best use case for GlobalScope is to send the important data (once a specific event occurs) no matter what will happen to the current flow
    example: Error reporting (the report must be sent in any possible way)

  • @sherazali6324
    @sherazali6324 4 года назад +1

    @CodingWithMitch I love the content you create please keep up the good stuff like this.

  • @j2shoes288
    @j2shoes288 4 года назад

    I think you've up'd your game, and giving quality videos. Cheers. ( I've already joined some other course, otherwise, I would join your course ). Maybe I might do so, anyway, this lockdown ( and hence lack of contracting dev roles ) means, I've had time to actually watch some of these videos.

  • @mkpazon_
    @mkpazon_ 4 года назад +2

    The GlobalScope.launch has the same behaviour of declaring a nested CoroutineScope isn't it?
    CoroutineScope(Dispatchers.Default).launch {
    CoroutineScope(Dispatchers.Default).launch {
    // has no association with parent
    }
    }

  • @sifatulhaque6170
    @sifatulhaque6170 4 года назад +1

    I was looking forward to become a founding member but didn’t see any discount.
    Has the discount promo been removed ?

  • @prakashshukla3558
    @prakashshukla3558 4 года назад +1

    Thumbnail of the month 🏆

  • @JeffTycz
    @JeffTycz 4 года назад +4

    What about doing a video on error handling in coroutines. I would be interested in this topic since it's a little different than you normally would handle exceptions and such

  • @mohitsinghrawat503
    @mohitsinghrawat503 4 года назад

    woow just amazing... never ever got this kind of explanation.. love from India

  • @bjornk.567
    @bjornk.567 4 года назад +1

    Unfortunately your example is flawed... You could replace both GlobalScope.launch { } calls with CoroutineScope(IO).launch { } calls. The output then is still the same. The reason why it behaves that way is that you actually create a new scope with a new parent here -- whether you use GlobalScope or CoroutineScope.

  • @silvahawk
    @silvahawk 3 года назад

    I remember in some demo video, you used GlobalScope on a showToast() helper method to run Toast on main thread, is that not the recommended way to call run Toast normally?

  • @knoppix20
    @knoppix20 4 года назад

    Mitch what model of microphone you use?

  • @kgandkg
    @kgandkg 4 года назад +2

    Damn I learnt this today. 🙏. Also be very careful with Fonts.

  • @fourcade7851
    @fourcade7851 4 года назад +1

    Hi, how are you? Could you please make me lesson on recyclerview about multiselect in JAVA
    . Thanks beforehand bro

  • @irfanirawansukirman4809
    @irfanirawansukirman4809 4 года назад

    Thanks mitch 👍

  • @michaelmutinda2567
    @michaelmutinda2567 4 года назад

    good job

  • @andy_lamax
    @andy_lamax 4 года назад

    Hi, You have good content. But I am sorry to say that GlobalScope.launch is not the same as CoroutineScope(Main).launch(Dispatchers.Default) as stated at 6:23. Yes, the GlobalScope uses the default dispatcher internally, but know that you can even use the GlobalScope to launch coroutines in the main thread. i.e. GlobalScope.launch(Dispatchers.Main). Thats not how structured concurrency works. GlobalScope just means, everything will be launch in the global scope as a child.

    • @codingwithmitch
      @codingwithmitch  4 года назад +2

      Yes I think the way I said that was confusing. The point I was trying to make was GlobalScope will pull from the same thread pool as Dispatchers.Default. That's all.

  • @bagadeshkumarr9502
    @bagadeshkumarr9502 3 года назад

    Sorry mitch. That is not an issue with global scope. Issue is structured concurrency.

  • @kingsleyetoka2792
    @kingsleyetoka2792 4 года назад

    Hello Mitch, Thanks a lot for the videos. Can you make a video on cache invalidation with room or any persistence layer. Am a bit confused on when to fetch new data or use existing data in local cache. Thanks a lot

    • @codingwithmitch
      @codingwithmitch  4 года назад +1

      Save a timestamp when the data was refreshed. Then after x days refresh it

  • @foreverrafs
    @foreverrafs 4 года назад

    Hello Mitch, How do you detect when a CoroutineWorker has been cancelled from within the doWork method when the work gets cancelled by the WorkManager

    • @codingwithmitch
      @codingwithmitch  4 года назад

      just add an invokeOnCompletion on the parent job. It will always fire when the job is complete or canceled

    • @foreverrafs
      @foreverrafs 4 года назад

      @@codingwithmitch I'm launching a suspendCoroutine inside the doWork. It doesn't seem to have an invokeOnCompletion method

  • @aabhishek4911
    @aabhishek4911 4 года назад

    Hi , just out of curiosity , are all of your coroutines videos in a course ? or are you planning something like that ? or they are all independent of each other

    • @codingwithmitch
      @codingwithmitch  4 года назад +1

      Nah just adding to a youtube playlist

    • @aabhishek4911
      @aabhishek4911 4 года назад

      @@codingwithmitch Great , can i get the link to the playlist :)

    • @codingwithmitch
      @codingwithmitch  4 года назад

      @@aabhishek4911 Look on my channel

    • @aabhishek4911
      @aabhishek4911 4 года назад

      @@codingwithmitch , Thanks , On a different note , in your course Powerful android apps with architecture , are you using data binding ? from the overview it does not look like that , if not using any reason for that ?

  • @bayraminanc885
    @bayraminanc885 4 года назад

    hi,
    laucn{
    .....
    }
    laucn{
    .....
    }
    Does this code snipped when running in courotine, is it working sequantially or paralel?

  • @charuwaka1
    @charuwaka1 4 года назад

    can I use the global scope with delay for this method recyclerView.scrollToPosition(position)?

  • @omkarpawar1741
    @omkarpawar1741 4 года назад

    can you make a video to explain the mess around how can we Access Media files using raw paths in Android R , Android deprecated the Uri - DATA / MediaStore.MediaColumns#DATA in Android Q , They suggested to use "context.getContentResolver.openInputStream(Uri)" instead it will work with Android, but there are various Libraries like FFMPeg and others which require direct file access(there is an issue with pipe protocol. for ffmpeg), which was prohibited, in Android Q, then in Android R the announced raw file paths access fro media paths will be allowed, but there is no documentation for that , there is furter confusion how would this Affect Android Q and the previous versions, its the strangest development around Android , can you please explain

    • @codingwithmitch
      @codingwithmitch  4 года назад

      Files and accessing them on android has always been such a MESS. This is something I've stayed away from. There's so many edge cases and weird "one off" rules. It's not fun and very confusing.
      Maybe in the future but no plans right now.

  • @wattheshet
    @wattheshet 4 года назад

    just a feedback on your site. Turns out you have to login when choosing to become a member. I tried to become a member as guest did not work. You should do something about that or show a dialog let the want to be member know.

    • @codingwithmitch
      @codingwithmitch  4 года назад +1

      Always working on the website. Finding the time is difficult.

    • @wattheshet
      @wattheshet 4 года назад +1

      @@codingwithmitch Focus on that. That's where you get money :D

  • @tarlamas
    @tarlamas 4 года назад +1

    Neat explanation! GJ
    GJ= Good Job not GlobalScope Job :P

  • @ChrisAthanas
    @ChrisAthanas 4 года назад

    Engagement

  • @HienNguyen-xn7tr
    @HienNguyen-xn7tr 4 года назад

    now im always careful of globalscope

  • @oscarperry641
    @oscarperry641 4 года назад

    LIKE!

  • @francescomarzo307
    @francescomarzo307 4 года назад

    That's the answer at the question everybody wants to know...Lebron, what's your decision?
    ruclips.net/video/RTeCc8jy7FI/видео.html