-
Notifications
You must be signed in to change notification settings - Fork 605
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
Move away from using WithConstraints
#30
Conversation
|
||
onCommit(result) { | ||
// Execute the onRequestCompleted callback if we have a new result | ||
result?.also { onRequestCompleted(it) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider running this in the same block as the result = it
in the CoilRequestActor callback instead of returning to composition with an onCommit; store the received callback in a MutableState in case it changes and call it from the state value
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done, I'm liking where this has landed 👍. Thanks for the help!
val requestWidth = constraints.requestWidth.value | ||
val requestHeight = constraints.requestHeight.value | ||
var result by state<RequestResult?> { null } | ||
val callback = mutableStateOf(onRequestCompleted) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this a state? this value is never changed and onRequestCompleted
is defined as a param
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was something @adamp mentioned in #30 (comment)
WithConstraints is not suitable for how we're using it, so we're moving to Modifier.onSizeChanged(). This required some changes to how CoilImage is implemented. While here we now use the new launchInComposition() function.
Due to using the wrong key parameter to the outer `remember`. Also fixed the state which holds the current callback.
WithConstraints
is not suitable for how we're using it, so we're moving toModifier.onSizeChanged()
(which is based onModifier.onPositioned
). This required some changes to how CoilImage is implemented. While here, I also migrated us to the newlaunchInComposition()
to launch our Coil request.