Mark M. | has entered the room |
Aug 13 | 7:25 PM |
Mark M. | turned on guest access |
Aug 13 | 8:05 PM |
Aaron | has entered the room |
Mark M. |
hello, Aaron!
|
Mark M. |
how can I help you today?
|
Aaron |
Hey Mark. Today I have one question, about p.126 in the Architecture Components book
|
Mark M. |
OK
|
Aaron |
In the last paragraph on that page, you say "Most developers will not be creating their own LifecycleObserver classes ... Instead, developers will tend to use observers created by others. Most notable among those is LiveData"
|
Aaron |
I'm confused by the terminology here
|
Mark M. |
what version of the book are you looking at?
|
Aaron |
0.9
|
Mark M. |
ah, OK, I was looking at 0.10
|
Aaron |
Oops. Must have missed that
|
Aaron |
Anyway
|
Mark M. |
OK, I now have that open and I see your quoted passage
|
Aaron |
My understanding is that LiveData would be the "observable" and the "observer" would be your Observer object in which you override the onChanged() method. So why are we calling LiveData an observer?
|
Aug 13 | 8:10 PM |
Mark M. |
yeah, that's poorly phrased
|
Mark M. |
part of the confusion is that Google uses "observer" as a term in many different places
|
Mark M. |
for example, a LiveData Observer is not a LifecycleObserver
|
Mark M. |
a LiveData has a LifecycleObserver in its implementation
|
Mark M. |
so the LiveData is observing lifecycle events and using them to control its operation, including what it passes along to its own observers
|
Mark M. |
I have made a note to cover this more in the next update to this book
|
Aaron |
ok, I am reviewing documentation to make sure I understand, sec
|
Aug 13 | 8:15 PM |
Mark M. |
the point that I'm trying to make is that while the Lifecycle stuff is available to everyone, it is relatively low level and you are more likely to use things that themselves use the Lifecycle stuff (LiveData, Uber's AutoDispose library for RxJava, etc.)
|
Aaron |
ok, that makes sense, I need to come back to this later after a break but I think that clears it up
|
Aaron |
and by "LiveData Observer" you mean android.arch.lifecycle.Observer<T>, correct?
|
Mark M. |
yes
|
Aaron |
ok great.
|
Aaron |
That's all I've got, thanks
|
Mark M. |
you're welcome!
|
Aaron |
also, in case you are interested, I figured out the last problem we discussed about logging inside of retrofit callbacks
|
Aaron |
The problem was using getClass().getSimpleName() for the tag argument. getSimpleName() returns an empty string when called in an anonymous inner class, and evidently that prevents logcat from displaying the message. Calling getClass().toString() instead resolved it
|
Mark M. |
that's odd -- I use getSimpleName() a lot and I don't recall running into that
|
Mark M. |
but, anonymous inner classes are odd beasts, so I'm not completely surprised
|
Mark M. |
for temporary logging, I've taken to using the current date in YYYMMDD format, as it makes for a nice thing to filter on in the LogCat view
|
Mark M. |
glad to hear that you got it worked out!
|
Aug 13 | 8:20 PM |
Aaron |
yeah, and I also learned how to do some better logging with an interceptor, very helpful
|
Aaron |
ok, thanks for your help
|
Aaron |
take care
|
Mark M. |
you too!
|
Aaron | has left the room |
Aug 13 | 8:25 PM |
Mark M. | turned off guest access |