From 10eef592920f9c6a769b27e6e0e0bbd8a671f682 Mon Sep 17 00:00:00 2001 From: Patrick Michalik <120058021+patrickmichalik@users.noreply.github.com> Date: Sat, 29 Jun 2024 11:35:07 +0200 Subject: [PATCH] `CartesianChartModelProducer`: Make `Transaction` constructor public, and deprecate `createTransaction` --- .../core/cartesian/data/CartesianChartModelProducer.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/vico/core/src/main/java/com/patrykandpatrick/vico/core/cartesian/data/CartesianChartModelProducer.kt b/vico/core/src/main/java/com/patrykandpatrick/vico/core/cartesian/data/CartesianChartModelProducer.kt index 1e961f443..b9573558e 100644 --- a/vico/core/src/main/java/com/patrykandpatrick/vico/core/cartesian/data/CartesianChartModelProducer.kt +++ b/vico/core/src/main/java/com/patrykandpatrick/vico/core/cartesian/data/CartesianChartModelProducer.kt @@ -155,6 +155,7 @@ public class CartesianChartModelProducer(dispatcher: CoroutineDispatcher = Dispa } /** Creates a [Transaction] instance. */ + @Deprecated("Use the `Transaction` constructor.", ReplaceWith("Transaction()")) public fun createTransaction(): Transaction = Transaction() /** @@ -162,20 +163,20 @@ public class CartesianChartModelProducer(dispatcher: CoroutineDispatcher = Dispa * For suspending behavior, use [runTransaction]. */ public fun tryRunTransaction(block: Transaction.() -> Unit): Boolean = - createTransaction().also(block).tryCommit() + Transaction().also(block).tryCommit() /** * Creates a [Transaction], runs [block], and calls [Transaction.commit], returning its output. */ public suspend fun runTransaction(block: Transaction.() -> Unit): Deferred = - createTransaction().also(block).commit() + Transaction().also(block).commit() /** * Handles data updates. An initially empty list of [CartesianLayerModel.Partial]s is created and * can be updated via the class’s functions. Each [CartesianLayerModel.Partial] corresponds to a * [CartesianLayer]. */ - public inner class Transaction internal constructor() { + public inner class Transaction { private val newPartials = mutableListOf() private val newExtraStore = MutableExtraStore()