https://kotlinlang.org logo
#android-architecture
Title
# android-architecture
s

sammy nduba

03/22/2024, 8:41 AM
I am building an application using RXJAVA/Kotlin but I am stack on the onboarding session (user registration and login logic. Asking for guidance or any material that can help offer some solid guidance.
g

galex

03/22/2024, 11:45 AM
You're not explaining what your issue is, you'll need to give us more information if you want our help. Also note that nowadays we're using Coroutines instead of RxJava
s

sammy nduba

03/22/2024, 2:18 PM
I am in the customer experience department(maintaining fintech applications). As part of my project I am to handle an onboarding task for user registration. The project entails acquiring user details and preserving them within room. username, userLastName, setting pin so that on next login event the user is only logs in with their set pin
Copy code
@SuppressLint("CheckResult")
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        super.onViewCreated(view, savedInstanceState)
        
        viewModel = ViewModelProvider(this).get(AuthViewModel::class.java)

//        viewModel = ViewModelProvider(this, authViewModelFactory).get(AuthViewModel::class.java)
        binding.viewmodel = viewModel

        RxView.clicks(binding.registerButton)

    }

    override fun onDestroyView() {
        super.onDestroyView()
        disposable.clear()
    }
    

    override fun onStarted() {
        binding.ProgressBar.visibility = View.VISIBLE
    }

    override fun onSuccess() {
        binding.ProgressBar.visibility = View.GONE
//        binding.registerButton.setOnClickListener{
//            viewModel.register()
//        }
    }

    override fun onFailure(message: String) {
        binding.ProgressBar.visibility = View.GONE
    }
Here is what I have been working on, my viewModel is attached down here:
Copy code
package com.register.ViewModel

import android.annotation.SuppressLint
import androidx.databinding.ObservableField
import androidx.lifecycle.ViewModel
import com.google.android.material.textfield.TextInputEditText
import com.register.DB.User
import com.register.Repository.UserRepository
import com.register.Utils.AuthListener
import io.reactivex.Flowable
import io.reactivex.Observable
import io.reactivex.disposables.CompositeDisposable
import io.reactivex.subjects.BehaviorSubject

class AuthViewModel (private val repository: UserRepository) : ViewModel() {



    var firstName = ObservableField<String>("")
    var lastName = ObservableField<String>("")
    var inputId = ObservableField<String>("")


    private val disposables = CompositeDisposable()
    var authListener: AuthListener? = null



    fun registerUser() {
        val user = User (
            uid = 0,
            firstName = firstName.get(),
            lastName = lastName.get()

        )

    }


}