I guess this has to do with Type erasure but I can...
# announcements
t
I guess this has to do with Type erasure but I can't get a solution, I want to have a centralized function for firebase callback, so I have something like this:
Copy code
fun <T> dataAsFlow(){
    //ValueEventListener impl start
    val type= object : GenericTypeIndicator<List<T>>() {}
    val result = dataSnapshot.getValue(type)
    // emit result
    //ValueEventListener impl end
}
The problem is data is getting deserialized into
List<HashMap<String, String>>
instead of
List<T>
. It works well if I am using the real type, say, e.g
List<Category>
instead of
List<T>
t
What JSON library do you use ?
t
None, firebase sdk comes with it’s own inner deserializer
d
Make the function inline and the type T reified
t
@Dico yes I tried that earlier but there was no luck
d
Then I think it's because of a bug with reified types.
Might be this one
t
Ha okay thanks.. I’ll have to be duplicating code for now
d
There might be a workaround
But it's bit difficult to explain on the phone
Ill try. You can try using a KType parameter, which you pass typeInfo<T>() into. Then you do a deep conversion from that to some other representation which your library might have.
t
Thanks I’ll try that out