Kotlin StateFlow Tutorial | StateFlow vs LiveData vs SharedFlow | CheezyCode - Hindi

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • Kotlin Flow Tutorial - Learn what is stateflow? Learn the difference between shared flow, stateflow, and livedata. Learn what is actual difference between shared flow and state flow with example. State Flow maintains the last value or the latest value emitted in the flow. State Flow is also a shared flow but with single buffer to keep the conflated values in the flow.
    LiveData transformation are executed on main thread whereas in StateFlow you have flowOn operator to execute the transformation on different dispatchers. LiveData is commonly used in Repository although it requires Lifecycle object to work. For these scenarios, it is recommended to use StateFlow. Learn what is Mutable State Flow and how it is different from Shared Flow and LiveData. Learn all these with example in Kotlin Flows in Hindi.
    Topics covered -
    1. Shared Flow - Hot Stream Examples
    2. Shared Flow vs State Flow
    3. What is State Flow?
    4. StateFlow vs LiveData
    4. Complete Example of StateFlow & MutableStateFlow
    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

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

  • @abdulbasitbhatti2489
    @abdulbasitbhatti2489 5 месяцев назад +1

    I just completed this Flows series. Thank you CheezyCode for providing such straightforward and clear explanation videos and tutorials. I am an Android Developer and whenever I need to learn something new, I visit CheezyCode first. You have helped me a lot in my Android development journey. Thank you, again.

  • @deepakpitaliya8932
    @deepakpitaliya8932 6 дней назад

    Just completed whole series. Great tutorial. Thank you for such clear and concise explanations.

  • @shubhamshinde-lt7hr
    @shubhamshinde-lt7hr Год назад +3

    Thank you for making this playlist
    You've made flow simple 😊

  • @khyatichavda415
    @khyatichavda415 27 дней назад

    Great tutorial and channel I had a career break of 6yr and while learning kotlin corutine and flows amazing explanation help me a lot thank you so much 🙏

  • @saqiblatif786
    @saqiblatif786 2 месяца назад

    Nice instructor.
    Hr topic clarity k sth smjhaya hai.

  • @rizwansworld
    @rizwansworld Месяц назад

    Thanks man. Really well explained!

  • @amanpahari690
    @amanpahari690 9 месяцев назад

    beautiful series of 6 vedios short, simple & crystal clear, Thnks sir🙏

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

    Sir Maja hi aa gaya you are really confidence booster 😍😍😍😍😍,Sir aur videos bachi hai is playlist me ? I am preparing for interview in top MNC is this playlist enough ? and Sir one more thing aap kaha job karte ho ?

    • @CheezyCode
      @CheezyCode  2 года назад +3

      thank you...interview ke liye I guess kaafi hai ...bas MVVM mei integrate aur karlo...uspe video dalni hai thoda samay lenge...but jaldi he upload karta hu....ek US based company hai...Noida mei dev center....

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

      @@CheezyCode Ok Sir thanks for the guidance 🥰

  • @sumeetchawla3545
    @sumeetchawla3545 Год назад +1

    Explained in very simple terms. Great !!! Keep it up !

  • @DnyaneshwarMahajan-e8b
    @DnyaneshwarMahajan-e8b 9 месяцев назад

    Excellent, Outstanding. You made Flow simple!!

  • @ihareshvaghela
    @ihareshvaghela 6 месяцев назад

    I appreciate your clear communication. Thanks!

  • @rishabhgarg6692
    @rishabhgarg6692 Год назад

    Best, simple clear, Thank you for such quality contents

  • @rocksolid111
    @rocksolid111 8 месяцев назад

    Simple and sweet explanation.... with no bakhwas like angragi videos.😄

  • @2chotti
    @2chotti 2 месяца назад

    Brilliant videos. Thank you so much

  • @basavarajashok
    @basavarajashok Год назад

    Simple and clear . Thank u ☺️

  • @aruaru1801
    @aruaru1801 2 года назад +1

    Sir, plz make a video on Unit testing Mockito, JUnit, Roboelectric

  • @mysuperemecy
    @mysuperemecy Год назад

    Best explanation ever

  • @naveennaik1889
    @naveennaik1889 2 года назад +2

    Thanks for the video , Its really helpfull , I just wanted to know is there any videos coming on these flows ??? i means is der any major concepts remaining in this flows section ??? coz i am preparing for interview on ur video basis . . . major topics

    • @CheezyCode
      @CheezyCode  2 года назад +5

      Majorly yehi hoga...baaki operators he h...uski koi limit nahi...concepts isse deep mei nahi puchne chaiye interview mei

  • @kishorramani007
    @kishorramani007 Год назад

    Thanks for this series :)

  • @vikrantsaini437
    @vikrantsaini437 Год назад

    Explanation at the easiest level! However, I have a question here.
    When explaining difference between LiveData and StateFlow, you said that Livedata is lifecycle aware but if we are collecting a flow inside a coroutine scope then does that means StateFlow is also lifecycle aware, as coroutine also has a lifecycle scope?

    • @CheezyCode
      @CheezyCode  Год назад +1

      Not directly aware but linked via coroutine scope

  • @iiitsricity3171
    @iiitsricity3171 Год назад

    Tussi great ho aap🙇

  • @RAJSINGH-mr7hq
    @RAJSINGH-mr7hq 2 года назад

    Superb sir 👌 👏

  • @56omkarkalel86
    @56omkarkalel86 2 года назад

    Mind blowing sir 🔥🔥🔥❤️❤️❤️

  • @RitikaGuleria-o1y
    @RitikaGuleria-o1y Год назад

    nice content sir

  • @user-yn7xl1ct5h
    @user-yn7xl1ct5h Год назад

    Thank you so much for the lovely tutorials. You explain very nicely.
    I have a question If we use SharedFlow with replay 1 then Isn't it the same as StateFlow?

    • @CheezyCode
      @CheezyCode  Год назад

      State Flow will provide you only current state. But let's say as you subscribe, emitter starts emitting...you will be getting 2 values at the same time(one because of replay and other one will be currently emitted value)...but with state Flow you will only get 1 value and that will be the latest one no matter what.
      Semantic difference hai...stateflow means flow having state

    • @CheezyCode
      @CheezyCode  Год назад

      Hope this helps 🤘🏻

    • @rexitspersonal8353
      @rexitspersonal8353 10 месяцев назад

      @@CheezyCode okey it means sharedFlow is not giving us latest value where as stateFlow is giving latest value right ?

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

    very nice and well explained...

  • @tusharvarankar6553
    @tusharvarankar6553 Год назад

    Good explanation of flow...thank you for this smooth understandable video....can you make a video for Android HAL (camera, audio, media player,BLe etc) concept please.

  • @androiddev7267
    @androiddev7267 2 года назад +1

    was this last video of flows series?

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

      Inhone number nai daala 1 2 karke mera v bhatkao ho gaya tha 😅

    • @CheezyCode
      @CheezyCode  2 года назад +2

      Playlist h 😂 jitne hai yehi h....

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

      @@CheezyCode ok sir

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

    Bhai Shared flow to samajh main aagaya and State flow bhi but State Flow ka kuch real world example miljata to samajhne main asani hoti aaur, jaise aapne shared flow ka example deke samjhaya cinema hall wala.. waisa kuch real world scenario main or else programming main kab use kare shared flow wo jan.na hai

    • @CheezyCode
      @CheezyCode  2 года назад +1

      Jahan pe livedata use kar rahe ho...waha pe stateflow se replace kardo...notes wali app mei replace karke dikhata hu jaldi he

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

      @@CheezyCode Sahi hai bhai just post kiya aapne, dekh raha hun StateFlow vs LiveData. Notes app

  • @kishorramani007
    @kishorramani007 Год назад

    Timimg at 5:38, shows that item ("5") collected before emitting why this output?

  • @no.bakwas
    @no.bakwas 2 месяца назад +1

    The difference in last 10:21 , isn't it between flow and live data rather than state flow and live data??

    • @CheezyCode
      @CheezyCode  2 месяца назад

      State Flow is a flow?

    • @no.bakwas
      @no.bakwas 2 месяца назад

      @@CheezyCode yes, stateFlow is a flow. I am saying you said and labelled the difference as 'LIVEDATA VS STATEFLOW' when it doesn't contain any particular property of stateFlow, all difference are of flow. Label ' livedata vs flow' is more accurate imo

    • @CheezyCode
      @CheezyCode  2 месяца назад

      Yes... generally people use stateflow to replace livedata that is why I have written this.

    • @no.bakwas
      @no.bakwas 2 месяца назад

      @@CheezyCode ok understood.
      Nice video btw. All of your videos are really helpful. Thank you very much for creating.

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

    Very good

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

    Thanks Sir

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

    hello sir, what is Rxjava??
    i m confused for Rxkava n liveData both are same ya different??

    • @CheezyCode
      @CheezyCode  2 года назад +1

      RxJava - duniya hai poori..
      LiveData - uska minuscule version hai...RxJava ka ek concept hai uska chota sa implementation hai....

  • @vikassharma-by4kw
    @vikassharma-by4kw 10 месяцев назад

    बहुत बढ़िया, साला कन्फ्यूज कर रखा था

  • @temposharma1220
    @temposharma1220 Год назад

    If I need to return non-stream kind of data like api response of any profile, so should I use flow or simple suspend function?

  • @Mohit-gb9dv
    @Mohit-gb9dv 2 года назад

    /* different topics */
    Sir , I have some data which I want to use in my entire app but dont want to use bundle or put extra method to send data to different activities or fragment
    Is there any way to do that please tell me

    • @CheezyCode
      @CheezyCode  2 года назад +1

      you can keep them in application object - but risky hoga toh keep it as singleton...make sure you don't pollute the global object...warna soch ban jaati hai baad mei ki sab kuch global pe he rakhdo....jetpack data store can also be used , create a wrapper around it to get the data from that...single place of getting and storing the object.

    • @CoCAttackArena
      @CoCAttackArena Год назад

      @@CheezyCode sir shared preference nahi use kar sakte kya??

  • @tusharjain7626
    @tusharjain7626 9 месяцев назад

    Personal note: stateFlow vs livedata

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

    At 6:35 what if we used replay in sharedflow will it collect since emit has stopped after 6 ms.

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

      yes that's why it is a special type of Shared Flow...isme ek concept aur hai - Conflation ka - i.e. it will keep the latest value

    • @CheezyCode
      @CheezyCode  2 года назад +1

      Good question hai waise....that means you understood the concepts well... 🤘

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

      @@CheezyCode Also coroutineScope does not have lifecycle so what happens if app is closed, will it still work or stop.

    • @CheezyCode
      @CheezyCode  2 года назад +1

      Scopes hote hai coroutines ke...like viewmodel scope and lifecycle Scope... activity destroy hogi toh lifecycle Scope bhi destroy hojayega...uske andar ka flow bhi....app close pe activity destroy nahi hui hogi toh maintain hona chaiye

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

      @@CheezyCode let me rephrase it, what is scope of "CoroutineScope(...).launch " this piece of code . I want to know scope of this. The lifecycle,global scopes I understood but scope of code in quotation I do not know

  • @NiteshSingh-bv9lu
    @NiteshSingh-bv9lu 2 года назад

    good video. but i want help in socket tcp client server so can you help me here

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

      ?

    • @NiteshSingh-bv9lu
      @NiteshSingh-bv9lu 2 года назад

      @@CheezyCode how to send data from our app to laptop?

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

      Via bluetooth karlo..socket tak mat pahocho...

    • @NiteshSingh-bv9lu
      @NiteshSingh-bv9lu 2 года назад

      @@CheezyCode haa but wapas data socket server se lenaa bhi hai naa like TCP client or TCP server dono use krnaa hai.ye chij Bluetooth me kese hogaa

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

    Thanku Sir....Awesome....