Jul 27 | 8:50 AM |
Mark M. | has entered the room |
Mark M. | turned on guest access |
Jul 27 | 8:55 AM |
Paul R. | has entered the room |
Mark M. |
hello, Paul!
|
Mark M. |
I'd ask "how can I help you today?", but I think that I know the answer... :-)
|
Paul R. |
Good morning. I just sent you some email about my questions for today. I'll give you a chance to read the message.
|
Mark M. |
regarding the SO question, "2" feels like the standard JVM way of naming anonymous inner classes
|
Mark M. |
if you think of all those wonderful stack traces you get, where listeners and whatnot show up as numbered things
|
Mark M. |
(BTW, for anyone reading this transcript, https://stackoverflow.com/q/57229715/115145 is the question)
|
Mark M. |
this is the sort of Kotlin thing that might vary by environment (Kotlin/JVM vs. Kotlin/JS)
|
Paul R. |
Correct which makes me thihk "this" is not what I think it is.
|
Paul R. |
i.e. "this::class.simpleName"
|
Mark M. |
"this" should be your anonymous instance of Human
|
ansh s. | has entered the room |
Mark M. |
but, on the JVM, that's just an object from an anonymous inner class of whatever class your function is in
|
Mark M. |
(BTW, hello Ansh -- I will be with you shortly!)
|
Paul R. |
Should be and if it is, then simpleName is not working per the spec or I don't understand something. I'm guessing the latter.
|
Jul 27 | 9:00 AM |
ansh s. |
hello, and no problem
|
Mark M. |
ah, I see
|
Mark M. |
when you say "spec", do you really mean the language specification, or just the KDocs?
|
Paul R. |
KDocs, which I repeat in the question.
|
Mark M. |
my guess is that it's a documentation bug
|
Mark M. |
but, that's just a guess
|
Paul R. |
The compiler and the docs are consistent fwiw.
|
Mark M. |
I don't understand what you mean there, sorry
|
Mark M. |
BTW, in Kotlin/JS 1.3.41, I get null for the simpleName
|
Mark M. |
View paste
|
Mark M. | |
Mark M. |
you can try that for yourself in https://klassbook.commonsware.com/scratchPad.html
|
Mark M. |
(which is a site that I'm still working on, so I apologize for any hiccups)
|
Mark M. |
so, I'm back to "it might vary by platform (Kotlin/JVM vs. Kotlin/JS)"
|
Mark M. |
and the docs might have been written with Kotlin/JS in mind or something
|
Jul 27 | 9:05 AM |
Mark M. |
let me take a question from Ansh, and I can follow up with you in a bit
|
Mark M. |
Ansh: hi! how can I help you today?
|
Paul R. |
For the same code you get a different result than I do.
|
ansh s. |
So i was getting a bit confused about how to handle livedata with a room db having multiple tables and many to many relations
|
ansh s. |
My UI model will have a Class A with {id, name and List<B>} where B is another class having {id, name}
|
Mark M. |
LiveData itself only cares about your queries and their results -- it does not care about the number of tables or the nature of any relations
|
Mark M. |
(technically, LiveData does not even care about the queries, as it is a data holder -- the Room InvalidationTracker cares about the queries and their results)
|
ansh s. |
i have thus 2 database entities A and B and a relational entity AB. I handled the inserion part: adding id, name in A and all the Bs objects in B followed by their id-id relations in entity AB
|
ansh s. |
But how can i return a livedata
|
ansh s. |
My dao is now an abstract class
|
Mark M. |
I assume that you are handling all of that work in a @Transaction method on your DAO
|
Jul 27 | 9:10 AM |
ansh s. |
yes
|
Mark M. |
I don't recall @Transaction supporting much in the way of a return value, though
|
Mark M. |
let alone LiveData
|
ansh s. |
i can't return a value in a transaction?
|
Mark M. |
you can, but Room isn't generating the code for creating the return value
|
Mark M. |
you are on your own for that
|
ansh s. |
yes, right, i remember being able to do that in another project, but this oe uses single livedata streams and now i have extended it to use multiple entities, i don't know how to get a livedata of that
|
ansh s. |
this one*
|
Mark M. |
you would need to create it yourself, I imagine
|
Mark M. |
I'm not certain what data type you are planning on it being a LiveData of, though
|
Mark M. |
insert operations return an ID value
|
Mark M. |
so, your @Transaction method is getting a handful of ID values (for A, for B, for AB)
|
Mark M. |
are you looking to return a LiveData of those IDs?
|
ansh s. |
yes, all encapsulated in a completely new entity AB_ui ={A's Values , List<B> objects}
|
ansh s. |
Should i use some better wordings for A/B class ? They are like A note and a tag. A note can have many tags
|
Mark M. |
then isn't that a separate @Query method on your DAO, that your @Transaction method delegates to after doing the inserts?
|
Jul 27 | 9:15 AM |
ansh s. |
yes, for insertion , it does. i can make an abstact @Query method for getting A, B and AB resppectively too, But i don't know, weather they should return A/B/AB or LiveData<A>, LiveData<B>,...etc
|
Mark M. |
LiveData does not have a zip() operator, though there is at least one open source one floating around
|
ansh s. |
whats a zip operator?
|
Mark M. |
zip() is a method you can use in RxJava to say "combine the outputs of these reactive types into a single object" which itself is delivered reactively
|
Mark M. |
you would zip your A result, your B result, and your AB result into the single result representing that entire data structure
|
Mark M. |
zip() would wait until all three of those results are in before emitting the combined output
|
ansh s. |
and the result is itself a single stream?
|
Mark M. |
yes
|
Mark M. |
that's the sort of thing you would need if you wanted your @Transaction to return a LiveData<A_Plus_B_Plus_AB>
|
ansh s. |
oh, then that's really what i want.
|
ansh s. |
and thats not possible with room/livedata, right?
|
Jul 27 | 9:20 AM |
Mark M. |
this has come up before, and I know that there is at least one open source library that offers a zip() transformation for LiveData
|
Jul 27 | 9:20 AM |
ansh s. |
is it possible to use mutable livedata here?
|
Mark M. |
though I think that the developer who brought all this up in chat wound up rolling his own zip() implementation
|
ansh s. |
wow
|
Mark M. |
MediatorLiveData is somewhat more likely, but you will need something like that
|
Mark M. |
it's kinda a pain
|
Mark M. |
Kotlin coroutines simplify this a ton
|
ansh s. |
ohh
|
Mark M. |
but poke around and see if you can find an existing zip() for LiveData in a library
|
Mark M. |
let me take another question from Paul, and I'll be back with you in a bit
|
ansh s. |
oh okay
|
Mark M. |
Paul: back to you! what would you like to talk about next?
|
Paul R. |
Back to my SO issue: It seem to work in JS for you but not for me and another person on JVM.
|
Mark M. |
I am not terribly surprised
|
Paul R. |
The other guy on the Kotlinlang Slack says it feels like a bug got introduced.
|
Mark M. |
possibly -- as somebody pointed out on a related question that I had, "this is the sort of thing that I would expect would vary by platform"
|
Paul R. |
I'm guessing it is a Java 7 -> Java 8 bug.
|
Mark M. |
that's a question for JetBrains, I guess
|
Paul R. |
Correct and I shall make it so. :-)
|
Jul 27 | 9:25 AM |
Paul R. |
Now if you would tell me about your attention to Kotlin vs Android and "bump"
|
Mark M. |
"Are you interested in having us "bump:" Kotlin issues for you?" -- I'm not completely certain what you mean by "Kotlin issues"
|
Mark M. |
if you mean literally things in their issue tracker, I think I have only ever filed one issue
|
Paul R. |
The issue I posted to SO is not Android.
|
Paul R. |
not Android related.
|
Mark M. |
if you mean "can I use the Stack Overflow bump feature of the Warescription for pure Kotlin questions", yes, though I think I need to update my site to support that
|
Mark M. |
I take a peek at the SO question tags and look for "android"
|
Paul R. |
Yes, it is a tagging issue.
|
Mark M. |
yeah, I've added a to-do item to support questions tagged "kotlin" as well as questions tagged "android"
|
Paul R. |
I think you need your own tag. :-)
|
Mark M. |
give me a week or two to get around to that
|
Mark M. |
in the meantime, a workaround would be to temporarily add the android tag, use the bump, then remove the android tag
|
Mark M. |
though the 24-hour waiting period rule would still apply
|
Paul R. |
Yup.
|
Mark M. |
but, probably next weekend if all goes well, I'll support the kotlin tag directly
|
Mark M. |
thanks for pointing this out!
|
Jul 27 | 9:30 AM |
Mark M. |
let me take another question from Ansh, and I'll swing back to you after that
|
Paul R. |
Are there any cases where, for a person having to learn both coroutines and Rx, you would say: learn both.
|
Mark M. |
Ansh: back to you! do you have another question?
|
Mark M. |
(Paul: if you have to maintain an existing Rx codebase, you'd need to learn enough Rx to do that -- otherwise, I think coroutines will be the long-term Android answer)
|
ansh s. |
no , i was actually just thinking about what should i do with my app now, i actually have a very less time to push the new relations version
|
ansh s. |
Maybe i will be removing livedata for now, i don't know rx java much
|
Mark M. |
I can't really comment on that, as I know little about your app, its requirements, and your deadlines :-)
|
ansh s. |
also, have you written something about custom views? there is a lot of mess and confusion in the official docs
|
Mark M. |
there is a chapter on it in *The Busy Coder's Guide to Android Development*
|
Mark M. |
but I only covered some simpler scenarios
|
Mark M. | |
Mark M. |
it has never been documented very well
|
ansh s. |
well, i will be looking into the book then, thanks!
|
Jul 27 | 9:35 AM |
ansh s. |
i am gonna go now, have a great day/evening/ night :)
|
Mark M. |
you too!
|
Mark M. |
Paul: back to you!
|
ansh s. | has left the room |
Paul R. |
I like your answer re: Rx. Music to my ears. And that does it for me. See you in a few weeks, btw.
|
Mark M. |
very nice! see you then!
|
Jul 27 | 9:50 AM |
Paul R. | has left the room |
Jul 27 | 10:00 AM |
Mark M. | turned off guest access |