diff --git a/coroutines/README.md b/coroutines/README.md index d62d68bce..9ba73e652 100644 --- a/coroutines/README.md +++ b/coroutines/README.md @@ -18,11 +18,11 @@ Now we can call a parse query using a synchronous style, this is possible when w ```kotlin launch { // Coroutine builder - val cat = ParseQuery.getQuery(...).find() + val cat = ParseQuery.getQuery(...).coroutineFind() // get cats without callback } ``` -We use a coroutine builder because `find()` is a suspend function. +We use a coroutine builder because `coroutineFind()` is a suspend function. We can also, use a function like a coroutine builder, it will be provider us a flexibility call our query without any extensions function. @@ -56,7 +56,7 @@ launch { // Coroutine builder setPassword("my pass") setEmail("email@example.com") }.also { - signUp() + coroutineSignUp() } } ``` diff --git a/coroutines/src/main/java/com/parse/coroutines/cloudfunction/ParseCloudCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseCloudCoroutinesExtensions.kt similarity index 92% rename from coroutines/src/main/java/com/parse/coroutines/cloudfunction/ParseCloudCoroutinesExtensions.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseCloudCoroutinesExtensions.kt index 94a935ae7..7e774c5d8 100644 --- a/coroutines/src/main/java/com/parse/coroutines/cloudfunction/ParseCloudCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseCloudCoroutinesExtensions.kt @@ -1,6 +1,6 @@ @file:JvmName("ParseCloudCoroutinesExtensions") -package com.parse.coroutines.cloudfunction +package com.parse.coroutines import com.parse.ParseCloud import kotlin.coroutines.resume @@ -14,4 +14,4 @@ suspend fun callCloudFunction(functionName: String, params: Map else continuation.resumeWithException(e) } } -} \ No newline at end of file +} diff --git a/coroutines/src/main/java/com/parse/coroutines/read/parse_object/ParseObjectCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesExtensions.kt similarity index 81% rename from coroutines/src/main/java/com/parse/coroutines/read/parse_object/ParseObjectCoroutinesExtensions.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesExtensions.kt index a5749b401..210148d99 100644 --- a/coroutines/src/main/java/com/parse/coroutines/read/parse_object/ParseObjectCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesExtensions.kt @@ -1,14 +1,13 @@ @file:JvmName("ParseObjectCoroutinesExtensions") -@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER") -package com.parse.coroutines.read.parse_object +package com.parse.coroutines import com.parse.ParseObject import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -suspend fun ParseObject.fetch(): T { +suspend fun ParseObject.suspendFetch(): T { return suspendCoroutine { continuation -> fetchInBackground { obj, e -> @@ -18,7 +17,7 @@ suspend fun ParseObject.fetch(): T { } } -suspend fun ParseObject.fetchIfNeeded(): T { +suspend fun ParseObject.suspendFetchIfNeeded(): T { return suspendCoroutine { continuation -> fetchIfNeededInBackground { obj, e -> @@ -36,4 +35,4 @@ suspend fun ParseObject.fetchFromLocal(): T { else continuation.resumeWithException(e) } } -} \ No newline at end of file +} diff --git a/coroutines/src/main/java/com/parse/coroutines/write/parse_object/ParseObjectCoroutinesWriteExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesWriteExtensions.kt similarity index 78% rename from coroutines/src/main/java/com/parse/coroutines/write/parse_object/ParseObjectCoroutinesWriteExtensions.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesWriteExtensions.kt index f4434dec3..ce3512c0c 100644 --- a/coroutines/src/main/java/com/parse/coroutines/write/parse_object/ParseObjectCoroutinesWriteExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseObjectCoroutinesWriteExtensions.kt @@ -1,14 +1,13 @@ @file:JvmName("ParseObjectCoroutinesWriteExtensions") -@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER") -package com.parse.coroutines.write.parse_object +package com.parse.coroutines import com.parse.ParseObject import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -suspend fun ParseObject.save() { +suspend fun ParseObject.suspendSave() { return suspendCoroutine { continuation -> saveInBackground { if (it == null) continuation.resume(Unit) @@ -17,11 +16,11 @@ suspend fun ParseObject.save() { } } -suspend fun ParseObject.pin() { +suspend fun ParseObject.suspendPin() { return suspendCoroutine { continuation -> pinInBackground { if (it == null) continuation.resume(Unit) else continuation.resumeWithException(it) } } -} \ No newline at end of file +} diff --git a/coroutines/src/main/java/com/parse/coroutines/read/query/ParseQueryCoroutinesBuilder.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesBuilder.kt similarity index 74% rename from coroutines/src/main/java/com/parse/coroutines/read/query/ParseQueryCoroutinesBuilder.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesBuilder.kt index f978549d4..2030acfc0 100644 --- a/coroutines/src/main/java/com/parse/coroutines/read/query/ParseQueryCoroutinesBuilder.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesBuilder.kt @@ -1,12 +1,9 @@ @file:JvmName("ParseQueryCoroutinesBuilder") -@file:Suppress("EXTENSION_SHADOWED_BY_MEMBER") -package com.parse.coroutines.read.query +package com.parse.coroutines import com.parse.ParseObject import com.parse.ParseQuery -import com.parse.coroutines.read.ParseQueryOperation -import com.parse.coroutines.read.ParseQueryOperationImpl import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Job import kotlinx.coroutines.launch @@ -21,4 +18,4 @@ fun CoroutineScope.launchQuery( return launch(context) { block.invoke(ParseQueryOperationImpl(query)) } -} \ No newline at end of file +} diff --git a/coroutines/src/main/java/com/parse/coroutines/read/query/ParseQueryCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesExtensions.kt similarity index 89% rename from coroutines/src/main/java/com/parse/coroutines/read/query/ParseQueryCoroutinesExtensions.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesExtensions.kt index e8071fdf5..a0749d22f 100644 --- a/coroutines/src/main/java/com/parse/coroutines/read/query/ParseQueryCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryCoroutinesExtensions.kt @@ -1,6 +1,6 @@ @file:JvmName("ParseQueryCoroutinesExtensions") -package com.parse.coroutines.read.query +package com.parse.coroutines import com.parse.ParseObject import com.parse.ParseQuery @@ -8,7 +8,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException -suspend fun ParseQuery.find(): List { +suspend fun ParseQuery.suspendFind(): List { return findInternal() } @@ -25,7 +25,7 @@ internal suspend fun ParseQuery.findInternal(): List { } } -suspend fun ParseQuery.get(id: String): T { +suspend fun ParseQuery.getById(id: String): T { return getInternal(id) } @@ -59,7 +59,7 @@ internal suspend fun ParseQuery.firstInternal(): T { } } -suspend fun ParseQuery.count(): Int { +suspend fun ParseQuery.suspendCount(): Int { return countInternal() } @@ -74,4 +74,4 @@ internal suspend fun ParseQuery.countInternal(): Int { else continuation.resumeWithException(e) } } -} \ No newline at end of file +} diff --git a/coroutines/src/main/java/com/parse/coroutines/read/ParseQueryOperation.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperation.kt similarity index 82% rename from coroutines/src/main/java/com/parse/coroutines/read/ParseQueryOperation.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseQueryOperation.kt index bfc0d6bca..8f0ecc642 100644 --- a/coroutines/src/main/java/com/parse/coroutines/read/ParseQueryOperation.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperation.kt @@ -1,8 +1,8 @@ -package com.parse.coroutines.read +package com.parse.coroutines interface ParseQueryOperation { suspend fun find(): List suspend fun get(id: String): T suspend fun first(): T suspend fun count(): Int -} \ No newline at end of file +} diff --git a/coroutines/src/main/java/com/parse/coroutines/read/ParseQueryOperationImpl.kt b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperationImpl.kt similarity index 63% rename from coroutines/src/main/java/com/parse/coroutines/read/ParseQueryOperationImpl.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseQueryOperationImpl.kt index 93f29537a..4a6a8f53a 100644 --- a/coroutines/src/main/java/com/parse/coroutines/read/ParseQueryOperationImpl.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseQueryOperationImpl.kt @@ -1,11 +1,7 @@ -package com.parse.coroutines.read +package com.parse.coroutines import com.parse.ParseObject import com.parse.ParseQuery -import com.parse.coroutines.read.query.countInternal -import com.parse.coroutines.read.query.findInternal -import com.parse.coroutines.read.query.firstInternal -import com.parse.coroutines.read.query.getInternal class ParseQueryOperationImpl(private val query: ParseQuery) : ParseQueryOperation { @@ -16,4 +12,4 @@ class ParseQueryOperationImpl(private val query: ParseQuery) override suspend fun first(): T = query.firstInternal() override suspend fun count(): Int = query.countInternal() -} \ No newline at end of file +} diff --git a/coroutines/src/main/java/com/parse/coroutines/user/ParseUserCoroutinesExtensions.kt b/coroutines/src/main/java/com/parse/coroutines/ParseUserCoroutinesExtensions.kt similarity index 89% rename from coroutines/src/main/java/com/parse/coroutines/user/ParseUserCoroutinesExtensions.kt rename to coroutines/src/main/java/com/parse/coroutines/ParseUserCoroutinesExtensions.kt index 28188bc38..09606e80e 100644 --- a/coroutines/src/main/java/com/parse/coroutines/user/ParseUserCoroutinesExtensions.kt +++ b/coroutines/src/main/java/com/parse/coroutines/ParseUserCoroutinesExtensions.kt @@ -1,13 +1,13 @@ @file:JvmName("ParseUserCoroutinesExtensions") -package com.parse.coroutines.user +package com.parse.coroutines import com.parse.ParseUser import kotlin.coroutines.resume import kotlin.coroutines.resumeWithException import kotlin.coroutines.suspendCoroutine -suspend fun ParseUser.signUp(): ParseUser { +suspend fun ParseUser.suspendSignUp(): ParseUser { return suspendCoroutine { continuation -> signUpInBackground { e -> if (e == null) continuation.resume(this)