parse-community / Parse-SDK-Android

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

Dependency Injection with Parse SDK #1042

Closed Berki2021 closed 3 years ago

Berki2021 commented 4 years ago

Hello,

I don't know if anybody already asked this question before: Is it possible to use dependency Injection in Android, when using the Parse SDK? Currently, I am thinking that its impossible, because in Parse you have to use classes or at east should use classes, when you want to initiate the object with its variables.

I am new to Parse, and I am new to dagger hilt, so maybe I am thinking totally wrong.

This is my class and I don't know If it is possible to use dependency Injection with this current approach: (Kotlin)

@ParseClassName("User")
class User(private val _username: String, private val _password: String, private val _email: String) : ParseUser() {

    constructor() : this(_username = "", _password = "", _email = "")

    fun signUpWithOutVerification() = apply {
        username = _username
        setPassword(_password)
        email = _email
        signUpInBackground()
    }

    fun logIn() = logInInBackground(_username, _password) ?: Timber.e("logIn Error")

    fun logOut() = logOutInBackground() ?: Timber.e("logOut Error")

    fun updateCredential(key: String, value: Any) = getCurrentUser().apply {
        put(key, value)
        saveInBackground()
    } ?: Timber.e("Update failed")

    fun deleteUser() = getCurrentUser().apply {
        deleteInBackground()
        logOut()
    } ?: Timber.e("Delete failed")
phillwiggins commented 3 years ago

Hey

I'm using Hilt in my Android application that uses the Parse SDK. What exactly are you trying to inject? The code snippet above doesn't actually contain any Hilt code?