Skip to content

Commit 6101aae

Browse files
committed
feat: add @stable annotation to domain models for Compose stability
- Add compose-runtime dependency to core module (compileOnly) - Add @stable annotation to: Book, Category, Line, TocEntry, AltTocEntry, AltTocStructure This enables Compose compiler to recognize these models as stable, preventing unnecessary recompositions when passed to composables.
1 parent b31f425 commit 6101aae

7 files changed

Lines changed: 14 additions & 0 deletions

File tree

core/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ kotlin {
2222
commonMain.dependencies {
2323
implementation(libs.kotlinx.serialization.json)
2424
implementation(libs.kotlinx.serialization.protobuf)
25+
// Compose runtime for @Stable annotation (used by consuming Compose apps)
26+
compileOnly(libs.compose.runtime)
2527
}
2628

2729
commonTest.dependencies {

core/src/commonMain/kotlin/io/github/kdroidfilter/seforimlibrary/core/models/AltToc.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
package io.github.kdroidfilter.seforimlibrary.core.models
22

3+
import androidx.compose.runtime.Stable
34
import kotlinx.serialization.Serializable
45

56
/**
67
* Describes an alternative TOC structure available for a book
78
* (e.g., Parasha/Aliyah alongside the primary chapter/verse).
89
*/
10+
@Stable
911
@Serializable
1012
data class AltTocStructure(
1113
val id: Long = 0,
@@ -18,6 +20,7 @@ data class AltTocStructure(
1820
/**
1921
* Single entry inside an alternative TOC tree.
2022
*/
23+
@Stable
2124
@Serializable
2225
data class AltTocEntry(
2326
val id: Long = 0,

core/src/commonMain/kotlin/io/github/kdroidfilter/seforimlibrary/core/models/Book.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.kdroidfilter.seforimlibrary.core.models
22

3+
import androidx.compose.runtime.Stable
34
import kotlinx.serialization.Serializable
45

56
/**
@@ -20,6 +21,7 @@ import kotlinx.serialization.Serializable
2021
* @property hasTeamim Indicates if the book contains biblical cantillation marks (teamim)
2122
* @property hasNekudot Indicates if the book contains vowel points (nikud/nekudot)
2223
*/
24+
@Stable
2325
@Serializable
2426
data class Book(
2527
val id: Long = 0,

core/src/commonMain/kotlin/io/github/kdroidfilter/seforimlibrary/core/models/Category.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.kdroidfilter.seforimlibrary.core.models
22

3+
import androidx.compose.runtime.Stable
34
import kotlinx.serialization.Serializable
45

56
/**
@@ -11,6 +12,7 @@ import kotlinx.serialization.Serializable
1112
* @property level The level of the category in the hierarchy (0 for root categories)
1213
* @property order The display order of the category (lower values appear first)
1314
*/
15+
@Stable
1416
@Serializable
1517
data class Category(
1618
val id: Long = 0,

core/src/commonMain/kotlin/io/github/kdroidfilter/seforimlibrary/core/models/Line.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.kdroidfilter.seforimlibrary.core.models
22

3+
import androidx.compose.runtime.Stable
34
import kotlinx.serialization.Serializable
45

56
/**
@@ -11,6 +12,7 @@ import kotlinx.serialization.Serializable
1112
* @property content The original HTML content of the line
1213
* @property heRef The Hebrew reference/citation (e.g., "בראשית א, א")
1314
*/
15+
@Stable
1416
@Serializable
1517
data class Line(
1618
val id: Long = 0,

core/src/commonMain/kotlin/io/github/kdroidfilter/seforimlibrary/core/models/TocEntry.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package io.github.kdroidfilter.seforimlibrary.core.models
22

3+
import androidx.compose.runtime.Stable
34
import kotlinx.serialization.Serializable
45

56
/**
@@ -14,6 +15,7 @@ import kotlinx.serialization.Serializable
1415
* @property lineId The identifier of the associated line, or null if not linked to a specific line
1516
* @property isLastChild Indicates if this TOC entry is the last child of its parent
1617
*/
18+
@Stable
1719
@Serializable
1820
data class TocEntry(
1921
val id: Long = 0,

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ commons-compress = { module = "org.apache.commons:commons-compress", version.ref
4141
zstd = { module = "com.github.luben:zstd-jni", version.ref = "zstd-jni" }
4242
androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-activityCompose" }
4343
jsoup = { module = "org.jsoup:jsoup", version.ref = "jsoup" }
44+
compose-runtime = { module = "org.jetbrains.compose.runtime:runtime", version.ref = "compose" }
4445

4546
[plugins]
4647

0 commit comments

Comments
 (0)