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