-
Notifications
You must be signed in to change notification settings - Fork 643
Implement firebase-database Kotlin extension. #826
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
* use the type `T`, and not `? extends T`. | ||
*/ | ||
inline fun <reified T> DataSnapshot.getValue(): T? { | ||
var genericTypeIndicator = object : GenericTypeIndicator<T>() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: maybe use val
instead of var
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch!. Fixed
/retest |
* use the type `T`, and not `? extends T`. | ||
*/ | ||
inline fun <reified T> DataSnapshot.getValue(): T? { | ||
val genericTypeIndicator = object : GenericTypeIndicator<T>() {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
worth inlining into getValue
call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, fixed.
Also add an extension supporting Kotlin coroutines? I can provide a PR for this separately.
|
This extension may not work as expected since type is being erased at runtime. In order to fix that class type should be passed as parameter of the function or make the function inline and use reified. I don't think inlining this function is a good idea. So I will be passing the type as a parameter similar to the
|
It's an interesting suggestion @msasikanth If you could provide a PR it would be great. Please, do keep in mind that changes in the API are subject to internal approval. Thanks! |
@msasikanth Please let me know when you add that extension so that I can include it on #841 :) |
Absolutely, once I figure how to setup the project in Android Studio properly. I am having sync and test run issues with it. |
@rosariopfernandes , @rlazo I have created the PR for the extension |
No description provided.