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

Implement debugMode to verify container uses a backing field #121

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

mattmook
Copy link
Contributor

Fixes #117

So the checks aren't duplicated I've had to make debugModeContainerHostVerification public.

This PR only introduces a guardrail for ensuring container uses a backing field

@@ -79,13 +79,14 @@ public interface Container<STATE : Any, SIDE_EFFECT : Any> {
* @property idlingRegistry The registry used by the container for signalling idling for UI tests
* @property intentDispatcher The dispatcher used for handling incoming [orbit] intents
* @property repeatOnSubscribedStopTimeout A delay (in milliseconds) between the disappearance of the last subscriber and
* the stopping of the repeatOnSubscribed block
* @property debugMode Enables additional guardrail checks
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend branding this as StrictMode, the Fragment library also uses that pattern.

https://developer.android.com/reference/androidx/fragment/app/strictmode/FragmentStrictMode

public fun <STATE : Any, SIDE_EFFECT : Any> ContainerHost<STATE, SIDE_EFFECT>.debugModeContainerHostVerification() {
if (container.settings.debugMode) {
//
if (container != container) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you thought about a bundled lint check? I think it could check all the container() calls and check their PSI parent to be a property without a getter.

The benefit of that is contextual quick fix intentions in IDEA (Alt+Enter, Enter).

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

Successfully merging this pull request may close these issues.

Create guardrails
2 participants