Skip to content

Commit

Permalink
fix: use a LiveEvent instead of Livedata for api result (#151)
Browse files Browse the repository at this point in the history
Use LiveEvent so it only occurs once, this stops the livedata firing a second time if navigating
between the settings and pusher view.
  • Loading branch information
Chesire authored May 29, 2021
1 parent b6d268a commit 6a29e7d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions feature/pusher/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ dependencies {
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
implementation("com.chesire.lintrules:lint-gradle:1.2.6")
implementation("com.chesire.lintrules:lint-xml:1.2.6")
implementation("com.github.hadilq:live-event:1.2.3")
implementation("com.google.android.material:material:1.3.0")
implementation("com.squareup.okhttp3:okhttp:4.9.1")

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.chesire.pushie.pusher

import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.hadilq.liveevent.LiveEvent
import kotlinx.coroutines.launch

/**
Expand All @@ -14,7 +14,7 @@ class PusherViewModel(
private val clipboardInteractor: ClipboardInteractor
) : ViewModel() {

private val _apiState = MutableLiveData<ApiState>()
private val _apiState = LiveEvent<ApiState>()

/**
* The current state of the api request.
Expand Down

0 comments on commit 6a29e7d

Please sign in to comment.