Jetpack

data class Jetpack(val id: String = UUID.randomUUID().toString(), val name: String = String(), val price: Double = 0.0, val lastUpdated: Long = System.currentTimeMillis(), val lastSynced: Long = 0, val needsSync: Boolean = true, val formattedDate: String = lastUpdated.asFormattedDateTime())

Domain model representing a Jetpack library item in the application's data layer.

This is the core domain model used throughout the app for representing Jetpack library entries. It sits between the database layer (JetpackEntity) and the remote layer (FirebaseJetpack), serving as the single source of truth that the UI layer observes.

The model supports offline-first architecture with sync tracking:

  • lastUpdated: Timestamp when the item was modified locally

  • lastSynced: Timestamp of the last successful sync with Firebase

  • needsSync: Flag indicating if local changes need to be pushed to Firebase

Mapping extensions are provided to convert between layers:

Usage context:

  • UI layer displays lists and details of Jetpack items via dev.atick.feature.home.ui.home.HomeViewModel

  • Repository returns Flow> as the single source of truth

  • ViewModel wraps Jetpack data in dev.atick.feature.home.ui.home.HomeScreenData

  • Background sync uses needsSync flag to identify items requiring upload

Parameters

id

Unique identifier (UUID) for the Jetpack item, consistent across all layers.

name

Display name of the Jetpack library (e.g., "Compose", "Room", "Hilt").

price

Numeric value representing the item's price (demo field for CRUD operations).

lastUpdated

Unix timestamp (milliseconds) of the last local modification.

lastSynced

Unix timestamp (milliseconds) of the last successful Firebase sync.

needsSync

Boolean flag indicating if local changes haven't been synced to Firebase.

formattedDate

Human-readable date string derived from lastUpdated for UI display.

See also

Room database entity representing local storage

Firestore document representing remote storage

Repository providing Jetpack operations

dev.atick.feature.home.ui.home.HomeViewModel

ViewModel consuming Jetpack data

Constructors

Link copied to clipboard
constructor(id: String = UUID.randomUUID().toString(), name: String = String(), price: Double = 0.0, lastUpdated: Long = System.currentTimeMillis(), lastSynced: Long = 0, needsSync: Boolean = true, formattedDate: String = lastUpdated.asFormattedDateTime())

Properties

Link copied to clipboard
Link copied to clipboard
val id: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard

Extension function to map a Jetpack to a FirebaseJetpack.

Link copied to clipboard

Extension function to map a Jetpack to a JetpackEntity.