Skip to content

Commit

Permalink
CartesianChartModelProducer: Make Transaction constructor public,…
Browse files Browse the repository at this point in the history
… and deprecate `createTransaction`
  • Loading branch information
patrickmichalik committed Jun 29, 2024
1 parent 6eda1da commit 10eef59
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,27 +155,28 @@ public class CartesianChartModelProducer(dispatcher: CoroutineDispatcher = Dispa
}

/** Creates a [Transaction] instance. */
@Deprecated("Use the `Transaction` constructor.", ReplaceWith("Transaction()"))
public fun createTransaction(): Transaction = Transaction()

/**
* Creates a [Transaction], runs [block], and calls [Transaction.tryCommit], returning its output.
* 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<Unit> =
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<CartesianLayerModel.Partial>()
private val newExtraStore = MutableExtraStore()

Expand Down

0 comments on commit 10eef59

Please sign in to comment.