Skip to content

Instantly share code, notes, and snippets.

@aymenjegham
Last active December 11, 2022 19:29
Embed
What would you like to do?
class UserDatasourceImpl @Inject constructor(
private val auth: FirebaseAuth,
) : UserDatasource {
override fun registerUserWithEmailAndPassword(
userName: String,
password: String,
): NetworkResult<Any> {
lateinit var networkResponse: NetworkResult<Any>
auth.createUserWithEmailAndPassword(userName, password).addOnCompleteListener { task ->
if (task.isSuccessful) {
networkResponse = NetworkResult.Success(task.result)
}
}.addOnFailureListener { exception ->
networkResponse = NetworkResult.Error(message = exception.message)
}
return networkResponse
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment