Jetpack Compose - Remember Coroutine Scope Example | Side Effects | CheezyCode Hindi

  Рет қаралды 9,448

Cheezy Code

Cheezy Code

Жыл бұрын

Learn Jetpack Compose in Android. In this video, we'll be discussing two important concepts in Jetpack Compose: Launched Effect and Remember Coroutine Scope. If you're working with asynchronous operations in your Compose app, you need to know these concepts to manage your coroutines efficiently. First, we'll discuss Launched Effect, which allows you to start a coroutine when a composable is first composed or when a key value changes. This makes it perfect for handling one-off asynchronous operations like network requests or database queries. We'll show you how to use Launched Effect with a real-world example and explain how it works under the hood.
Next, we'll dive into Remember Coroutine Scope, which provides a CoroutineScope object that can be stored in a Composable to survive configuration changes. We'll discuss how this is different from the default CoroutineScope and how it can help you manage coroutines more efficiently. We'll also explain how CoroutineScope cancels coroutines when a composable is recreated due to configuration changes like screen rotations. We'll also compare Launched Effect and Remember Coroutine Scope, and show you which one to use for different use cases. We'll give you several examples of how to use both concepts, including handling network requests, database queries, and animations in your Compose app.
By the end of this video, you'll have a deep understanding of Launched Effect and Remember Coroutine Scope, and how they can help you build more efficient and reliable Compose apps. So, sit back, relax, and let's dive into the world of asynchronous programming in Jetpack Compose!. Everything is explained in Hindi (हिन्दी)
Topics covered -
1. Side Effects in Jetpack Compose.
2. Launched Effect Coroutine Scope Handling
3. RememberCoroutineScope Example
4. Difference between RememberCoroutineScope and Launched Effect.
Kotlin Flows Playlist -
• Kotlin Flows Tutorials
Jetpack Paging Tutorial -
• Android Paging 3 | Jet...
Complete Dependency Injection Playlist Link -
• Dagger 2 - Dependency ...
Complete Android Architecture Components Playlist -
• Android Architecture C...
Beginner series in Android Playlist (Hindi) -
• Android Tutorials Step...
Kotlin Beginners Tutorial Series -
• Kotlin Beginner Tutori...
For more info - visit the below link
www.cheezycode.com
We are social. Follow us at -
Facebook - / cheezycode
Twitter - / cheezycode
Instagram - / cheezycode

Пікірлер: 31
@rizwansworld
@rizwansworld Ай бұрын
Really cool explanation bhai. Thanks.
@sudhanshusharma9159
@sudhanshusharma9159 5 ай бұрын
counter stop noramlly. But If we rotate the screen, counter does not stop and weired value of counter it goes beyond 10 and keep on incresing. no matter how many times we rotate the screen. Any change in this as per latest doc?
@vinayshaw6238
@vinayshaw6238 Жыл бұрын
One doubt...We click on the start button and coroutine is started but what will happen if we again click on the start button even if the coroutine is not stopped.
@sukhwantsingh501
@sukhwantsingh501 10 ай бұрын
Hi can you please guide what is long term flutter or android native development.
@Shubhamkumar-ee8mi
@Shubhamkumar-ee8mi Жыл бұрын
Thank you so much sir. Query= So in coroutine scope we again get exception on device rotation than how we can avoid it, And what is the advantage of coroutine scope here .
@CheezyCode
@CheezyCode Жыл бұрын
exception aana is good in this case - this shows your coroutine will be cancelled...no memory leaks.... solution - to define this in view model and view model will handle your configuration changes. advantage is to call coroutines independently sab kuch apne haath mei h
@harjotsingh5570
@harjotsingh5570 Жыл бұрын
@@CheezyCode Then isn't it better to define the coroutines in ViewModel itself and have a state observable in the activity file?
@haseeb776
@haseeb776 Жыл бұрын
hi can you make detail video on native android vs react native in the context of deprecations? which framework/platform is getting more deprecations(classes, methods, libraries etc)? well as far I know google is renowned for deprecations!
@CheezyCode
@CheezyCode Жыл бұрын
With Android - We love deprecations 😁 jokes apart - video banana toh mushkil hai aise topic pe...react native although is good but native wali feel aana mushkil hota hai- later stage pe code spaghetti ban jati hai...
@haseeb776
@haseeb776 Жыл бұрын
​@@CheezyCode Sir I am very frustrated with native android! mjse developers yehi bolte hain react native me ajao its better option on the other hand flutter bhi rise kr rha hai. aur kotlin multi platform duniya ki sabse bakwas cheez hai google ki traf se.😂. where should I move?
@tanmaykhatri6061
@tanmaykhatri6061 Жыл бұрын
Thanks sir ji. When will this course be completed?
@CheezyCode
@CheezyCode Жыл бұрын
Basics saare covered h.. projects banayege bas ab
@iampradeephr
@iampradeephr Жыл бұрын
ok what if i declare a boolean variable in remember{} and then use it as key in LaunchedEffect() and on button click change the boolean to !boolean. it is same as using rememberCoroutineScope() right ??????
@CheezyCode
@CheezyCode Жыл бұрын
you can achieve the behavior but uska intention dusra hai....remembercoroutinescope is for running coroutines independently with the scope that is linked to your composable lifecycle....launched effect is used to run the coroutine when the initial composition happens...jo cheez jiske liye banai h ussi ka use karna hai bas....
@iampradeephr
@iampradeephr Жыл бұрын
@@CheezyCode shukriya, I rewatched it and understood.
@piyush288
@piyush288 11 ай бұрын
so the difference is just we can get exception on config changes by using rememberCoroutineScope? thats only?? @Cheezy Code
@ahsansyed4146
@ahsansyed4146 10 ай бұрын
that's not the only Advantage, we can run coroutine scope (rememberCoroutineScope) inside the button.
@theai2020
@theai2020 11 ай бұрын
At 10:46 the counter started from 11 any explanation
@shivamprajapati70018
@shivamprajapati70018 9 ай бұрын
Because of remember keyword
@ChocoByte
@ChocoByte Жыл бұрын
When will next video come? 🐤
@CheezyCode
@CheezyCode Жыл бұрын
done
@Shubhamkumar-ee8mi
@Shubhamkumar-ee8mi Жыл бұрын
Do we launch multiple blocks on same rememberCoroutineScope?
@CheezyCode
@CheezyCode Жыл бұрын
yes we can launch multiple coroutines
@udaysharma5228
@udaysharma5228 Жыл бұрын
Yes, also point to be noted, as scope is tied to the composable where the scope is generated, so if scope is getting used to launch co-routines in child composable, IF ANY of the child composable function disposed after launching co-routine, then the scope will not be cancelled and co-routine will keep on executing.
@balusekhar
@balusekhar Жыл бұрын
How to handle screen rotations then?
@CheezyCode
@CheezyCode Жыл бұрын
Viewmodel
@ChocoByte
@ChocoByte Жыл бұрын
@@CheezyCode ​ In Jetpack compose also, we use ViewModel ? to handle configuration changes? Or there is any alternative in compose?
@CheezyCode
@CheezyCode Жыл бұрын
ViewModels...will cover that in this playlist
@ChocoByte
@ChocoByte Жыл бұрын
@@CheezyCode okkk
@tabishkhan2012
@tabishkhan2012 Жыл бұрын
Hello Everyone app sabhi ka cheezy code me sawagat hai
@CheezyCode
@CheezyCode Жыл бұрын
😂
Avoiding common coroutines mistakes in Compose by Márton Braun
15:02
Kotlin by JetBrains
Рет қаралды 2,7 М.
World’s Largest Jello Pool
01:00
Mark Rober
Рет қаралды 110 МЛН
لقد سرقت حلوى القطن بشكل خفي لأصنع مصاصة🤫😎
00:33
Cool Tool SHORTS Arabic
Рет қаралды 28 МЛН
remember, by, and mutableStateOf explained
10:07
Brandan Jones
Рет қаралды 4,1 М.
Return a value from a Kotlin Coroutine Scope - Explained
6:32
Stevdza-San
Рет қаралды 18 М.
KMP vs. Flutter - Who Will Win The Cross-Platform Battle?
16:19
Philipp Lackner
Рет қаралды 40 М.