icerockdev / moko-mvvm

Model-View-ViewModel architecture components for mobile (android & ios) Kotlin Multiplatform development
https://moko.icerock.dev/
Apache License 2.0
995 stars 95 forks source link

postValue and setValue is removed in newer version #173

Closed mgoaldev closed 2 years ago

mgoaldev commented 2 years ago

when I use 0.11.0 version is work fine with postValue, but when I update to newer version (0.12.0), I got unresolved reference, can you make it again or should I use another way?

thanks before

   // LIVE DATA
    var mFacebookLoginData =
        MutableLiveData<FacebookLoginState>(LoadingFacebookLoginState())

    // USE CASE
    private val mFacebookLoginUseCase by KodeinInjector.instance<FacebookLoginUseCase>()

    fun getTokenFacebookMokko(fbId: String, email: String, name: String, avatar: String) {
        viewModelScope.launch() {
            mFacebookLoginData.postValue(LoadingFacebookLoginState())   //this postValue now is unresolved reference
            val request = FacebookLoginRequest(fbId, email, name, avatar)
            val response = mFacebookLoginUseCase.execute(request)
            processFacebookLoginResponse(response)
        }
    }

     /**
     * PROCCESS RESPONSE
     */
    fun processFacebookLoginResponse(response: Response<TokenDao>) {
        if (response is Response.Success) {
            mFacebookLoginData.postValue(
                SuccessFacebookLoginState(
                    response
                )
            )
        } else if (response is Response.Error) {
            mFacebookLoginData.postValue(
                ErrorFacebookLoginState(
                    response
                )
            )
        }
    }
Alex009 commented 2 years ago

@mgoaldev hi!

postValue and setValue now is extension functions for mobile only targets - https://github.com/icerockdev/moko-mvvm/blob/b4b2ed1a86451bd303aa0733ecd776be96c6f455/mvvm-livedata/src/mobileMain/kotlin/dev/icerock/moko/mvvm/livedata/postValue.kt#L7 to use it you should just add import.