This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import androidx.fragment.app.Fragment | |
import androidx.fragment.app.viewModels | |
import androidx.lifecycle.* | |
interface MyViewModelInterface { | |
val liveData: LiveData<String> | |
} | |
class MyViewModel:ViewModel(), MyViewModelInterface { | |
override val liveData = MutableLiveData<String>() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UploadFilesUsecase() : BaseObservable<UploadFilesUsecase.Listener>() { | |
interface Listener { | |
fun onFilesUploaded() | |
fun onFilesUploadFailed() | |
} | |
private val MAX_RETRIES = 3 | |
private val mutex = Mutex() | |
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UploadFilesUsecase() { | |
private val MAX_RETRIES = 3L | |
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO) | |
private val atomic = atomic<Flow<File>?>(null) | |
suspend fun uploadFiles(): Flow<File> { | |
atomic.value?.let { return it } | |
val channel = ConflatedBroadcastChannel<File>() |