Hildebrandt Tobias
04/30/2025, 9:06 AMUpdater
which is defined like this:
sealed external interface Updater<T> /* T | ((old: T) -> T) */
inline fun <T> Updater(
source: T,
): Updater<T> =
unsafeSpecialCast(source)
inline fun <T> Updater(
noinline source: (old: T) -> T,
): Updater<T> =
unsafeSpecialCast(source)
I know I can create these using functionalUpdate()
but how do I consume them?
Currently I do
this.onSortingChange = { newSorting ->
setSorting(newSorting.unsafeCast<SortingState>())
}
but it feels kind of wrong.
What is correct way to consume such an Updater
?Erik van Velzen
04/30/2025, 9:42 AMthis.onSortingChange = Updater<SortingState> { newSorting ->
setSorting(newSorting)
}
Does this work?Hildebrandt Tobias
04/30/2025, 9:44 AMHildebrandt Tobias
04/30/2025, 9:48 AMHildebrandt Tobias
04/30/2025, 11:28 AMuseReactTable<T>(
options = jso {
val (pagination, setPagination) = states.pagination // StateInstance<PaginationState>
this.state = jso<TableState> {
this.pagination = pagination
}
this.onPaginationChange = unsafeSpecialCast(setPagination)
}
)
turansky
04/30/2025, 12:01 PMUpdater
in factturansky
04/30/2025, 12:05 PMunsafeCast
or asDynamic
:
1. Probably you need it without reason, please check one more time
2. It can be typization error in wrappers (current case)turansky
04/30/2025, 12:05 PMHildebrandt Tobias
04/30/2025, 12:07 PMturansky
04/30/2025, 12:07 PMHildebrandt Tobias
04/30/2025, 12:07 PMHildebrandt Tobias
04/30/2025, 12:15 PMturansky
05/01/2025, 8:47 AM2025.5.0
😎