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

Chore: Remove deprecated Connectivity code #92

Merged
merged 2 commits into from
Jan 3, 2025
Merged

Conversation

jordond
Copy link
Owner

@jordond jordond commented Jan 3, 2025

BREAKING CHANGES

  • Removed Connectivity.Update class, Connectivity.updates flow and Connectivity.activeUpdates.
    • This class was removed so you need to use Connectivity.status
    • To get the monitoring status use Connectivity.monitoring or Connectivity.isMonitoring.
  • Connectivity.isMonitoring: StateFlow<Boolean> renamed to Connectivity.monitoring
  • Added Connectivity.isMonitoring: Boolean to replace the isMonitoring from Connectivity.Update

Migration

If you were using Connectivity.updates you need to migrate to the following:

// Old
connectivity.updates.collect { update ->
    updateState { state ->
        state.copy(
            monitoring = update.isActive,
            status = update,
        )
    }
}

// New
connectivity.statusUpdates.collect { status ->
    updateState { state ->
        state.copy(status = update, monitoring = connectivity.isMonitoring)
    }
}

If you need to also reactively update the monitoring status as well, you can do the following:

launch {
    connectivity.statusUpdates.collect { status ->
        updateState { state -> state.copy(status = update) }
    }
}

launch {
    connectivity.monitoring.collect { isMonitoring ->
        updateState { state ->  state.copy(monitoring = isMonitoring) }
    }
}

Or you can use Flow.merge:

connectivity.monitoring.combine(connectivity.statusUpdates) { isMonitoring, status ->
    updateState { state ->
        state.copy(status = update, monitoring = isMonitoring)
    }
}.collect()

@jordond jordond added this to the 2.0.0 milestone Jan 3, 2025
@jordond jordond added the breaking Includes a breaking change label Jan 3, 2025
@jordond jordond merged commit 331d24f into main Jan 3, 2025
5 checks passed
@jordond jordond deleted the chore/remove-deprecated branch January 3, 2025 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Includes a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant