#[Solved] Function is Executing Multiple Times For No Reason

1 messages · Page 1 of 1 (latest)

stuck thistle
#

So I Created a function Which Triggers on Event (User Prefs Update) It's get Executed Multiple Times for No Reason? Why is that?

#

Function is Executing Multiple Times For No Reason

stuck thistle
#

Anyone? From the team

small reef
stuck thistle
#

If i Remove that event nothing happens everything works fine. But I am using that event to perform some action.

small reef
#

Sounds like it's triggering off that event then.

Can you log the x-appwrite-event header?

stuck thistle
#

Sure

small reef
stuck thistle
#

No, I am updating My Preference using Accounts in the Android SDK.

small reef
stuck thistle
#

override suspend fun setUserPreference(type:String): Result<Boolean, DataError.FetchingError> {
return try {

        account.updatePrefs(mapOf("type" to "student"))

        Result.Success(true)


    } catch (e: AppwriteException) {
        when (e.type) {
            "general_rate_limit_exceeded" -> Result.Error(DataError.FetchingError.RATE_LIMIT_CROSSED)
            "document_not_found" -> Result.Error(DataError.FetchingError.REQUESTED_DOCUMENT_NOT_FOUND)
            "Unauthorized" -> Result.Error(DataError.FetchingError.NOT_ACCESS)
            else -> Result.Error(DataError.FetchingError.UNKNOWN_SERVER_ERROR)
        }
    } catch (e: Exception) {
        if (e is SocketTimeoutException) {
            Result.Error(DataError.FetchingError.TIMEOUT)
        } else {
            Result.Error(DataError.FetchingError.UNKNOWN_SERVER_ERROR)
        }
    }
}
#

This is Where i Am Updating the userPref

stuck thistle
#

Okay I Figured it Out, I Was Testing Jetpack Compose And I Forgot About Recomposition Which Triggered So Much Calls. Sorry for the inconvenience.

#

[Solved] Function is Executing Multiple Times For No Reason