parse-community / Parse-SDK-Android

The Android SDK for Parse Platform
https://parseplatform.org/
Other
1.88k stars 734 forks source link

Cannot use coroutines extension function save #1016

Closed LopsemPyier closed 4 years ago

LopsemPyier commented 4 years ago

Hello, I've import parse sdk and parse coroutines with

//Parse SDK
implementation "com.github.parse-community.Parse-SDK-Android:parse:1.23.1"
//Parse coroutines
implementation "com.github.parse-community.Parse-SDK-Android:coroutines:1.23.1"

And when I try to save a ParseObject with a coroutine, it use the parse method save and not the extension one. This is because they have the same name so the method win over the extension.

If I made a mistake when add dependency in my android project, I apologize but I tried with the README.md which isn't clear enought.

Thank you.

P.S: In the README.md it says for signUp :

launch { // Coroutine builder
    user = ParseUser().apply {
        setUsername("my name")
        setPassword("my pass")
        setEmail("email@example.com")
    }.also {
        signUp()
    }
}

but in fact the function is singUp.

Jawnnypoo commented 4 years ago

@oliveiradev Do you have any info or experience with this? Maybe we need to changes the names of the extension methods?

Jawnnypoo commented 4 years ago

In the mean time, I think if you add the extension import manually to the class, it will work.

oliveiradev commented 4 years ago

I think that the manual import will solve it, but change the method signature name can be a better solution, I'll see it ASAP

oliveiradev commented 4 years ago

@Jawnnypoo I see that the IDE suggests the correct import, do you have some suggestion about the way that we need to solve this?

Jawnnypoo commented 4 years ago

I didn't try this out myself, just going off of what @LopsemPyier mentioned. If it shows the correct imports by the IDE, then I don't think there is an issue here.

LopsemPyier commented 4 years ago

The IDE doesn't show the import I only got the save method define in parse. I only got these suggestions whiwh are from the parse sdk and not from the extension screen And I manually import the save method from the extension like this

import com.parse.coroutines.write.parse_object.save

It might not be an issue but I can't understand why it doesn't work

oliveiradev commented 4 years ago

@LopsemPyier I'll double check it, and if I got some problem I'll try to solve in the next days

LopsemPyier commented 4 years ago

OK thank you

shlusiak commented 4 years ago

Are there any updates on this? None of the couroutines seem usable to me, even when manually importing the function, the save of ParseObject is called, not the extension function. I suggest not shadowing the name but expose those functions using different names or parameters to be able to distinguish them when writing code.

oliveiradev commented 4 years ago

Hello guys,

I really would like that you guys take a look and left a comment if something should be better