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

Flag non-remembered State object creation #506

Open
bubenheimer opened this issue Jan 12, 2024 · 1 comment · May be fixed by #516
Open

Flag non-remembered State object creation #506

bubenheimer opened this issue Jan 12, 2024 · 1 comment · May be fixed by #516
Labels
triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@bubenheimer
Copy link
Contributor

android-maps-compose 4.3.0

It appears that accidental misuse of android-maps-compose state objects like MarkerState without remember() is common. It would be nice to have the UI/Lint flag such usages.

@bubenheimer bubenheimer added triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. labels Jan 12, 2024
@bubenheimer
Copy link
Contributor Author

Compose Runtime 1.5.0 added StateFactoryMarker to flag these usages. However, it is only applicable to function calls, not constructor calls. android-maps-compose uses constructor calls for creating State objects.

I have created https://issuetracker.google.com/issues/318054171 to extend StateFactoryMarker to constructor calls. Please consider voting for this issue or promoting it in other ways.

bubenheimer added a commit to bubenheimer/android-maps-compose that referenced this issue Jan 29, 2024
…thout remember or similar mechanisms.

The PR replaces public constructors on State objects with `invoke()` factory functions in public companion objects. `@StateFactoryMarker` can only be applied to functions, not constructors. The chosen constructor replacement approach minimizes the required refactoring impact on correct State object usages, requiring no refactoring in the vast majority of cases.

Fixes googlemaps#506
bubenheimer added a commit to bubenheimer/android-maps-compose that referenced this issue Feb 2, 2024
…thout remember or similar mechanisms.

The PR replaces public constructors on State objects with `invoke()` factory functions in public companion objects. `@StateFactoryMarker` can only be applied to functions, not constructors. The chosen constructor replacement approach minimizes the required refactoring impact on correct State object usages, requiring no refactoring in the vast majority of cases.

Fixes googlemaps#506
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
1 participant