From 020f48149be23dcad96ed668dca39c889d090c43 Mon Sep 17 00:00:00 2001 From: dece Date: Tue, 25 Jan 2022 19:36:59 +0100 Subject: [PATCH] PageViewModel: docs --- .../java/dev/lowrespalmtree/comet/PageViewModel.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt b/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt index 1a978b8..5034ab9 100644 --- a/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt +++ b/app/src/main/java/dev/lowrespalmtree/comet/PageViewModel.kt @@ -16,15 +16,20 @@ import java.nio.charset.Charset @ExperimentalCoroutinesApi class PageViewModel(@Suppress("unused") private val savedStateHandle: SavedStateHandle) : ViewModel() { + /** Currently viewed page URL. */ var currentUrl: String = "" - private var requestJob: Job? = null + /** Observable page viewer state. */ val state: MutableLiveData by lazy { MutableLiveData(State.IDLE) } - private var linesList = ArrayList() + /** Observable page viewer lines (backed up by `linesList` but updated less often). */ val lines: MutableLiveData> by lazy { MutableLiveData>() } + /** Observable page viewer latest event. */ val event: MutableLiveData by lazy { MutableLiveData() } - /** A non-saved list of visited URLs. Not an history, just used for going back. */ val visitedUrls = mutableListOf() + /** Latest request job created, stored to cancel it if needed. */ + private var requestJob: Job? = null + /** Lines for the current page. */ + private var linesList = ArrayList() enum class State { IDLE, CONNECTING, RECEIVING