I investigate boguszpawlowski Compose Calendar and I cannot find a way to track state changes of the component, because there are no callback for it. For example I need to get events only for current month (send a request) and after it I should show them in calendar. When user switch month I should send a request again. Author in description suggest using state hoisting for it.
In case you need to react to the state changes, or change the state from the outside of the composable, you need to hoist the state out of the Calendar composable:
@Composable
fun MainScreen() {
val calendarState = rememberCalendarState()
StaticCalendar(calendarState = calendarState)
// now you can manipulate the state from scope of this composable
calendarState.monthState.currentMonth = MonthYear.of(2020, 5)
}
I understand how to change current of initial month, but I do not know how to listen event when user swipe calendar or click the button to change month. How can I do it?