Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to track month state changes? #84

Closed
Foenix00001 opened this issue Nov 11, 2022 · 2 comments
Closed

How to track month state changes? #84

Foenix00001 opened this issue Nov 11, 2022 · 2 comments
Labels

Comments

@Foenix00001
Copy link

I cannot see the callback to track the event when user changes the current month. Is there a way to do something with current month (for example I need to load events of current month and show them)?

@boguszpawlowski
Copy link
Owner

Hi @Foenix00001! I believe you can use snapshotFlow function of Compose to react of every month change, e.g

val monthState = rememberSaveable(saver = MonthState.Saver()) {
    MonthState(initialMonth = YearMonth.now())
  }

  val calendarState = rememberCalendarState(
    monthState = monthState,
  )

  StaticCalendar(
    calendarState = calendarState,
  )
  
  LaunchedEffect(Unit) {
    snapshotFlow { monthState.currentMonth }
      .collect { currentMonth ->
        // viewModel.doSomething()
      }
  }

If you think that is not enough, feel free to write your suggestions.

@Foenix00001
Copy link
Author

thank you, it is exactly what I wanted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants