Conversation
|
f9cd243 to
5d31838
Compare
5d31838 to
7d4256f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Compose API Guidelines for components states that:
State<T> as a parameter
Parameters of type
State<T>are discouraged since it unnecessarily narrows the type of objects that can be passed in the function. Givenparam: State<Float>, there are two better alternatives available, depending on the use case:param: Float. If the parameter doesn’t change often, or is being read immediately in the component (composition), developers can provide just a plain parameter and recompose the component when it changes.param: () -> Float. To delay reading the value until a later time viaparam.invoke(), lambda might be provided as a parameter. This allows the developers of the component to read the value only when/if it is needed and avoid unnecessary work. For example, if the value is only read during drawing operation, only redraw will occur. This leaves the flexibility to the user to provide any expression, including theState<T>’s read:param = { myState.value }- read theState<T>’s valueparam = { justValueWithoutState }- plain value not backed by theState<T>param = { myObject.offset }- user can have a custom state object where the field (e.g.offset) is backed by themutableStateOf()DON’T
Do: