2.0.0-alpha.22
This release includes fixes and improvements and continues the API cleanup.
Breaking changes | Addressed |
---|---|
Minor | #722, #734, #736, #765, #776, #781 |
CartesianChartModelProducer
In CartesianChartModelProducer
, we’ve addressed concurrency issues and a problem where exceptions weren’t
propagated. Some changes have been made to the API, both to facilitate the fixes and to consolidate it.
The concurrency fixes apply to runTransaction
and Transaction.commit
. Because it wasn’t possible to make equivalent
corrections to tryRunTransaction
and Transaction.tryCommit
without rendering their behavior unpredictable, these two
functions are deprecated. All Transaction
s should now be run via runTransaction
and Transaction.commit
, which are
suspending functions.
While the deprecated functions—tryRunTransaction
and Transaction.tryCommit
—remain usable, we recommend that you
switch to runTransaction
and Transaction.commit
immediately to benefit from the concurrency fixes.
- Compose
- Views
In a ViewModel
, a solution such as the following can be used:
viewModelScope.launch(Dispatchers.Default) {
cartesianChartModelProducer.runTransaction { /* ... */ }
}
In a LaunchedEffect
, you can use this:
withContext(Dispatchers.Default) {
cartesianChartModelProducer.runTransaction { /* ... */ }
}
In a ViewModel
, for example, a solution such as the following can be used:
viewModelScope.launch(Dispatchers.Default) {
cartesianChartModelProducer.runTransaction { /* ... */ }
}
Remember to never run Transaction
s on the main thread.
If you’re using tryRunTransaction
in a coroutine and wish to keep this fire-and-forget behavior, call runTransaction
in a new coroutine. You can use launch
to do so.
runTransaction
and Transaction.commit
no longer return Deferred
implementations, so calls to await
should be
removed. These two functions now return at the same time at which await
would. Previously, it was possible to skip the
await
call and have control flow continue as soon as the processing of an update started. This, however, had no
practical benefit. One should either wait for an update to be processed or take a fire-and-forget approach, described
above.
build
is deprecated in favor of the CartesianChartModelProducer
constructor. Unlike build
, this constructor has no
dispatcher
parameter. This is because runTransaction
and Transaction.commit
inherit the call site’s
CoroutineContext
. To have a CartesianChartModelProducer
use a particular CoroutineDispatcher
, call its functions
from a CoroutineContext
that includes this dispatcher. In the snippet above, for example, runTransaction
does its work on
Dispatchers.Default
.
In Transaction
, updateExtras
has been deprecated and renamed to extras
for consistency.
createTransaction
has
been deprecated in favor of the Transaction
constructor. Keep in mind, however, that you should generally use
runTransaction
instead of creating a Transaction
directly.
Miscellaneous
- Compose
- Views
CartesianChartHost
now properly handles nested scroll.- Issues affecting
ShapeComponent
’s margin handling have been addressed. - We’ve resolved an issue where automatic padding for extreme
HorizontalAxis
labels reserved too much empty space in charts with zoom disabled. - Changes have been made to
Insets
and related APIs. Insets should now be requested via theensureValuesAtLeast
functions.ChartInsetter
has new function signatures. - Several APIs have been deprecated. See the deprecation messages for more information.
-
Several XML attributes have been renamed. The attributes with the old names are deprecated.
View or attribute set Old attribute name New attribute name CartesianChartView
chartHorizontalScrollingEnabled
scrollEnabled
CartesianChartView
chartZoomEnabled
zoomEnabled
TextComponentStyle
labelColor
android:color
Shape
dashGapLength
gapLength
-
We’ve resolved an issue where automatic padding for extreme
HorizontalAxis
labels reserved too much empty space in charts with zoom disabled. -
Changes have been made to
Insets
and related APIs. Insets should now be requested via theensureValuesAtLeast
functions.ChartInsetter
has new function signatures. -
Several APIs have been deprecated. See the deprecation messages for more information.