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

Closed
bubenheimer opened this issue Jan 12, 2024 · 2 comments · Fixed by #516
Closed

Flag non-remembered State object creation #506

bubenheimer opened this issue Jan 12, 2024 · 2 comments · Fixed by #516
Labels
released 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
@dkhawk dkhawk closed this as completed in 9ed3f7a Jul 3, 2024
googlemaps-bot pushed a commit that referenced this issue Jul 3, 2024
# [6.0.0](v5.0.3...v6.0.0) (2024-07-03)

### Bug Fixes

* fix release step ([#586](#586)) ([e5dc195](e5dc195))
* leverage `@StateFactoryMarker` to flag State object creation without remember or similar mechanisms. ([#516](#516)) ([9ed3f7a](9ed3f7a)), closes [#506](#506)
* Return early in rememberComposeBitmapDescriptor for invalid view size ([#533](#533)) ([db97e65](db97e65))

### BREAKING CHANGES

* leverage @StateFactoryMarker to flag State object creation without remember or similar mechanisms

Co-authored-by: Uli Bubenheimer <bubenheimer@users.noreply.github.com>
@googlemaps-bot
Copy link
Contributor

🎉 This issue has been resolved in version 6.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released 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
2 participants