Skip to content

Instantly share code, notes, and snippets.

@aymenjegham
Last active December 11, 2022 19:29
Show Gist options
  • Save aymenjegham/f190314932af9ed23239aba318b6b4c7 to your computer and use it in GitHub Desktop.
Save aymenjegham/f190314932af9ed23239aba318b6b4c7 to your computer and use it in GitHub Desktop.
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