Created
April 1, 2026 06:30
-
-
Save Mikkareem/e6798bc04e93c8c593bc592ec7a8eb58 to your computer and use it in GitHub Desktop.
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
| private fun Modifier.testComposed( | |
| value: Int | |
| ): Modifier = composed { | |
| DisposableEffect(value) { | |
| println("Started with value $value") | |
| onDispose { | |
| println("Disposed with value $value") | |
| } | |
| } | |
| this | |
| } | |
| @Composable | |
| fun ModifierComposedText() { | |
| val count1 = remember { mutableIntStateOf(0) } | |
| val count2 = remember { mutableIntStateOf(1) } | |
| Column { | |
| if(count2.value % 5 != 0) { | |
| Button( | |
| onClick = { count1.value++ }, | |
| modifier = Modifier.testComposed(count1.value) | |
| ) { | |
| Text("Count 1: ${count1.value}") | |
| } | |
| } | |
| Button( | |
| onClick = { count2.value++ }, | |
| ) { | |
| Text("Count 2: ${count2.value}") | |
| } | |
| } | |
| } |
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
| ========= INITIAL ============= | |
| Value: Count1 = 0, Count2 = 1 | |
| Visible Buttons: Count1, Count2 | |
| Logs: | |
| Started with value 0 | |
| ========= END ============= | |
| ========= CLICK COUNT1 BUTTON ============= | |
| Value: Count1 = 1, Count2 = 1 | |
| Visible Buttons: Count1, Count2 | |
| Logs: | |
| Disposed with value 0 | |
| Started with value 1 | |
| ========= END ============= | |
| ========= CLICK COUNT1 BUTTON ============= | |
| Value: Count1 = 2, Count2 = 1 | |
| Visible Buttons: Count1, Count2 | |
| Logs: | |
| Disposed with value 1 | |
| Started with value 2 | |
| ========= END ============= | |
| ========= CLICK COUNT1 BUTTON 10 TIMES ============= | |
| Value: Count1 = 12, Count2 = 1 | |
| Visible Buttons: Count1, Count2 | |
| Logs: | |
| Disposed with value 2 | |
| Started with value 3 | |
| Disposed with value 3 | |
| Started with value 4 | |
| Disposed with value 4 | |
| Started with value 5 | |
| Disposed with value 5 | |
| Started with value 6 | |
| Disposed with value 6 | |
| Started with value 7 | |
| Disposed with value 7 | |
| Started with value 8 | |
| Disposed with value 8 | |
| Started with value 9 | |
| Disposed with value 9 | |
| Started with value 10 | |
| Disposed with value 10 | |
| Started with value 11 | |
| Disposed with value 11 | |
| Started with value 12 | |
| ========= END ============= | |
| ========= CLICK COUNT2 BUTTON 3 TIMES ============= | |
| Value: Count1 = 12, Count2 = 4 | |
| Visible Buttons: Count1, Count2 | |
| Logs: | |
| ========= END ============= | |
| ========= CLICK COUNT2 BUTTON ================ | |
| Value: Count1 = 12, Count2 = 5 | |
| Visible Buttons: Count2 | |
| Logs: | |
| Disposed with value 12 | |
| ========= END ============= | |
| ========= CLICK COUNT2 BUTTON ================ | |
| Value: Count1 = 12, Count2 = 6 | |
| Visible Buttons: Count1, Count2 | |
| Logs: | |
| Started with value 12 | |
| ========= END ============= | |
| ========= CLICK COUNT1 BUTTON ================ | |
| Value: Count1 = 13, Count2 = 6 | |
| Visible Buttons: Count1, Count2 | |
| Logs: | |
| Disposed with value 12 | |
| Started with value 13 | |
| ========= END ============= |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment