Content

interface Content

Everything the catalogue holds — articles, issues, videos, media and publications — as seen by the profile currently active on the session.

Obtained from CGS.content. Each domain is its own small service with the same two shapes:

  • get(id, scope) observes one item as a StateFlow of CgsStreamState

  • all(…, scope) returns a PaginatedResource you observe through its state and advance with loadNextPage()

val issues = CGS.content().issues.all(pageSize = 20, scope = viewModelScope)
viewModelScope.launch { issues.state.collect { state -> render(state.items) } }

// From the list's scroll listener, as the user nears the end:
fun onNearEnd() = viewModelScope.launch { issues.loadNextPage() }

Session awareness

Every accessor here follows the session. When the signed-in account or the active profile changes, whatever was loaded is dropped and requested again against the new session — you never have to re-request after switching profiles. A reload that fails after such a switch carries at most what was cached for the new session, never the previous profile's content. While no one is signed in, every flow here reports CgsError.Auth.Missing, and picks up again on its own after the next sign-in.

Lifecycle

All of it is bound to the CoroutineScope you pass in: requests stop five seconds after nothing collects anymore, and resume on the next collection. Pass the scope of whatever is displaying the data — a viewModelScope, typically — and there is nothing to release by hand.

Properties

Link copied to clipboard
abstract val articles: Articles

Articles, whether they belong to an issue or stand on their own.

Link copied to clipboard
abstract val issues: Issues

Issues: one dated release of a publication, downloadable and readable page by page.

Link copied to clipboard
abstract val medias: Medias

Media: the publisher a set of publications belongs to.

Link copied to clipboard

Publications: a magazine, a newspaper, a video channel — whatever issues are published under.

Link copied to clipboard
abstract val videos: Videos

Videos, and the publications they are distributed under.