LiveData with Coroutines and Flow (Android Dev Summit '19)

  Рет қаралды 110,965

Android Developers

Android Developers

Күн бұрын

Пікірлер: 65
@saurabhsomani582
@saurabhsomani582 3 жыл бұрын
This talk is my go to #1 talk from this channel. I keep coming back and always learn something new every time I rewatch and refactor my code.
@adamhurwitz
@adamhurwitz 5 жыл бұрын
ViewModel - 10:45 Using .collect{ … } and .emit( … ) - 11:33 LiveData builder .asLiveData() - 11:45 .onStart{ ... } - 12:25 Replace LiveData switchMap - 13:00 Repositories - 13:20 Emit multiple values with flow{ ... } - 15:53 Working with non coroutine streams - 16:21
@mochadwi
@mochadwi 5 жыл бұрын
thank you very much for this summary @Adam Hurwitz
@ringoaikocascade
@ringoaikocascade 4 жыл бұрын
Would like to talk about testing but we don't have much time - 17:22
@yallam08
@yallam08 4 жыл бұрын
This testing joke at the end is hilarious 😂
@SociedadAndroide
@SociedadAndroide 4 жыл бұрын
This was amazing !! Thank you guys now I know how to use flow :) Keep up the great work!
@marlonlom
@marlonlom 5 жыл бұрын
Great review about livedata ando coroutines... After a year sharing similar topics
@codingwithmitch
@codingwithmitch 5 жыл бұрын
Are there any samples on github?
@RaymondChenon
@RaymondChenon 4 жыл бұрын
Sample with liveData. No Flow yet github.com/android/architecture-components-samples/blob/master/LiveDataSample/
@TheHiddenAndroid
@TheHiddenAndroid 5 жыл бұрын
Congrats to Yigit and Jose for a nice session! Just a bit silly that we have naming discrepancy in that we have lifecycleScope and viewModelScope but liveData {} is missing Scope suffix :/ And Jose, well done for lingering in the KZbin comments...
@josealcerreca4841
@josealcerreca4841 5 жыл бұрын
liveData launches a coroutine. The Scopes are just scopes that need `.launch` to launch the coroutine. Completely different things :)
@igorg.8624
@igorg.8624 5 жыл бұрын
Where are the Google samples for using Flow in android apps?
@marlonlom
@marlonlom 4 жыл бұрын
codelabs (?)
@theren8311
@theren8311 4 жыл бұрын
codelabs.developers.google.com/codelabs/advanced-kotlin-coroutines/#0
@marlonlom
@marlonlom 4 жыл бұрын
How can i unit test a method that contains a reference of a Flow thas is converted to a LiveData using the function 'asLIveData()' ????
@bjugdbjk
@bjugdbjk 3 жыл бұрын
quite informative and lively presentation. I tried this scenario, Having a flow emitter in the datasource and taking into the livedata in the Viewmodel and question is when I am observing this livedata in the activity and when app goes to background and come back to the foreground, flow is restarting again and it's not getting paused?
@benlu3523
@benlu3523 5 жыл бұрын
What a nice “Rx Java”
@josealcerreca4841
@josealcerreca4841 5 жыл бұрын
Nothing wrong with that!
@robkeazor9709
@robkeazor9709 5 жыл бұрын
You mean Flow? because Livedata is pretty different than RxJava
@cheesuscheetos4076
@cheesuscheetos4076 5 жыл бұрын
Flow is a reactive component, it is indeed made as an answer to RxJava. One of the most beautiful things about Kotlin and JetBrains in general is that they really care about consistency and having in house solutions. For them having to use a third party library for something that they can implement themselves and is important is bad. This in turn makes the language feel syntactically consistent and a complete whole. Precisely this is the reason why so many of us love Kotlin. For me Kotlin Coroutines and Flow have so far been a complete hit that has addressed many problems and made concurrency, reactive programming and switching between threads so much more manageable, readable, understandable and easier.
@preetgandhi1233
@preetgandhi1233 4 жыл бұрын
@@robkeazor9709 Can you Please explain me the difference and when to use which? I am having a use case to fetch the Data from an API and show it in View no more UI to Database Interaction needed. So what should i use?
@wahyukoco4562
@wahyukoco4562 2 жыл бұрын
do we need to use live data instead of state flow in presentation layer?
@tubun09
@tubun09 5 жыл бұрын
is there any public repo example of this?
@JoseAlcerreca
@JoseAlcerreca 5 жыл бұрын
We have a sample using the liveData builder but since Flow is experimental it'll take some time to be in official samples. github.com/android/architecture-components-samples/blob/master/LiveDataSample/
@charlietapping4518
@charlietapping4518 5 жыл бұрын
@@JoseAlcerreca Would be really useful if you could just post a GIST of how you would replace the repository liveData coroutine builder with flow, using the typical Room response whilst the network updates the db in the background
@josealcerreca4841
@josealcerreca4841 4 жыл бұрын
We used Flow in the ADS app: github.com/google/iosched/blob/adssched/mobile/src/main/java/com/google/samples/apps/iosched/ui/sessiondetail/SessionDetailViewModel.kt
@michaelnajera7958
@michaelnajera7958 5 жыл бұрын
17:51 What is this "caching behavior" that we lose if we ditch LiveData and just use Flow?
@yaroslavkulinich7155
@yaroslavkulinich7155 5 жыл бұрын
Livedata holds the last state. So if you unsubscribe from livedata and then subscribe again, you will receive the last emitted value. In case with flow, you always receive new value from fresh request.
@michaelnajera7958
@michaelnajera7958 5 жыл бұрын
​@@yaroslavkulinich7155 Thank you.
@karibui494
@karibui494 5 жыл бұрын
@@michaelnajera7958 you can just conflate the flow and it gets the same caching behaviour .
@michaelnajera7958
@michaelnajera7958 5 жыл бұрын
@@karibui494 I think I'd actually prefer not to get the cached value. To me, it violates the "single source of truth". But maybe I'm missing something. Is there a benefit to this default caching? All "caching" should come from my repository and not from something I don't control.
@igorg.8624
@igorg.8624 5 жыл бұрын
@@yaroslavkulinich7155 I believe RxJava PublishProcessor does this
@lokthar6314
@lokthar6314 4 жыл бұрын
Why would you use a WorkManager if you want to do a Http Request such as sending a tweet? (5:37)
@lokthar6314
@lokthar6314 3 жыл бұрын
@Ray If your App is doing a request while it's killed then this sounds like your App is not behaving right. App closed -> No requests, unless you do something like location tracking.
@anupkunwar5290
@anupkunwar5290 5 жыл бұрын
At 6:46 and 7:15 how can we retry the operation?
@Rajmanov
@Rajmanov 5 жыл бұрын
Super cool José!
@KhairulImam10100
@KhairulImam10100 5 жыл бұрын
I still having problem with testing my viewmodel that launches viewmodel corotuine scope and update livedata value inside that scope.
@JoseAlcerreca
@JoseAlcerreca 5 жыл бұрын
This is covered in today's testing talk!
@KhairulImam10100
@KhairulImam10100 5 жыл бұрын
@@JoseAlcerreca Cool!! waiting for it!
@alexneeky7920
@alexneeky7920 5 жыл бұрын
Why flow feels like rx java with extra steps?
@benlu3523
@benlu3523 5 жыл бұрын
Because it is a flow (flowable)
@dnkilic
@dnkilic 4 жыл бұрын
This is revolution!
@petrushoc
@petrushoc 5 жыл бұрын
Awesome presentation
@ViktorYakunin
@ViktorYakunin 5 жыл бұрын
Flow APIs are very similar to Rx, what is next? adding library with extensions to clone all Rx functionality?
@hinocenciopaulo
@hinocenciopaulo 5 жыл бұрын
Do you are pissed because your Rx knowledges are irrelevant right now?
@ViktorYakunin
@ViktorYakunin 5 жыл бұрын
@@hinocenciopaulo I'm using Kotlin in production since beta and Coroutines since experimental, so no. When you have a library (RxJava) that poisons all your codebase IMO its bad idea. But I must say that a lot of other technologies are on Rx stage, for example RxSwift, RxDart are there and Spring5 has async model as well that uses Rx too.
@Muthuraj
@Muthuraj 5 жыл бұрын
Flow is similar to Rx, but the major selling point for that is, it is multiplatform.
@phamgiang9149
@phamgiang9149 5 жыл бұрын
An additional point is that RxJava is a heavy library. Most of the time, developers don't use 99% of its power in the codebase :D
@igorg.8624
@igorg.8624 5 жыл бұрын
@@Muthuraj Is there anybody doing this type of multiplatform in production?
@marcopierucci4519
@marcopierucci4519 4 жыл бұрын
How about retry option?
5 жыл бұрын
Any flow video tutorial?
@help-ever
@help-ever 5 жыл бұрын
Source code for the app will be available soon after I/O.
@saungaye9717
@saungaye9717 2 жыл бұрын
Imagine a life you don't know English much and try to understand this alien things.
@NikhilMaurya10
@NikhilMaurya10 5 жыл бұрын
So livedata is also in the bin now. I like fast paced development but this is ridiculous.
@JoseAlcerreca
@JoseAlcerreca 5 жыл бұрын
Not in the bin at all! (Data Binding, Java users) but we thought it was interesting to show. Remember we didn't create or control the development of Flow.
@NikhilMaurya10
@NikhilMaurya10 5 жыл бұрын
@@JoseAlcerreca I guess it was bound to happen since popularity of Koltin was/is through the roof.
@martinseal1987
@martinseal1987 5 жыл бұрын
Where can I get that shirt
@josealcerreca4841
@josealcerreca4841 5 жыл бұрын
Limited edition :P
@tellvivk
@tellvivk 5 жыл бұрын
My man
@kyay10
@kyay10 5 жыл бұрын
Lookin' good
What’s new in Room (Android Dev Summit '19)
16:09
Android Developers
Рет қаралды 39 М.
Kotlin Coroutines 101 - Android Conference Talks
24:49
Android Developers
Рет қаралды 138 М.
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Мясо вегана? 🧐 @Whatthefshow
01:01
История одного вокалиста
Рет қаралды 7 МЛН
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Understanding Compose (Android Dev Summit '19)
36:15
Android Developers
Рет қаралды 73 М.
Fun with LiveData (Android Dev Summit '18)
19:20
Android Developers
Рет қаралды 104 М.
Performance myth busters (Android Dev Summit '19)
30:51
Android Developers
Рет қаралды 13 М.
Fragments: Past, present, and future (Android Dev Summit '19)
18:21
Android Developers
Рет қаралды 76 М.
Coroutines and Loom behind the scenes by Roman Elizarov
45:22
Kotlin by JetBrains
Рет қаралды 34 М.
Android Studio: Debugging tips n' tricks (Android Dev Summit '19)
18:58
Android Developers
Рет қаралды 58 М.
Transformers (how LLMs work) explained visually | DL5
27:14
3Blue1Brown
Рет қаралды 4,2 МЛН
Intro to the Zig Programming Language • Andrew Kelley • GOTO 2022
50:14
Sigma Kid Mistake #funny #sigma
00:17
CRAZY GREAPA
Рет қаралды 30 МЛН