This file contains 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
@Composable | |
fun Main() { | |
MyVerticalBox( | |
name = "box1", | |
modifier = Modifier.background(Color.Yellow) | |
) { | |
MyVerticalBox( | |
name = ">box2", | |
modifier = Modifier | |
.size(100.dp) |
This file contains 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
@Composable | |
private static final void Node2(final String name, Composer $composer, final int $changed, final int var3) { | |
$composer = $composer.startRestartGroup(1815931962); | |
int $dirty = $changed; | |
if ((var3 & 1) != 0) { | |
$dirty = $changed | 6; | |
} else if (($changed & 14) == 0) { | |
// ↓ where it is compared to the contents of the SlotTable. | |
$dirty = $changed | ($composer.changed(name) ? 4 : 2); | |
} |
This file contains 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
@Composable | |
fun Content() { | |
var state by remember { mutableStateOf(true) } | |
LaunchedEffect(Unit) { | |
delay(3000) | |
state = false | |
} | |
if (state) { | |
Node1() // ← This place is about to disappear. | |
} |
This file contains 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
@Composable | |
public static final void Content(@Nullable Composer $composer, final int $changed) { | |
... | |
// ↓↓↓↓Register the function to be called again↓↓↓↓ | |
if (var18 != null) { | |
var18.updateScope((Function2)(new Function2() { | |
public final void invoke(@Nullable Composer $composer, int $force) { | |
MainKt.Content($composer, $changed | 1); | |
} | |
})); |
This file contains 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
class ViewModel { | |
val state = mutableStateOf("init") | |
} | |
fun main() { | |
val viewModel = ViewModel() | |
lateinit var currentScope: String | |
val observations = mutableMapOf<Any, String>() | |
val snapshot = Snapshot.takeMutableSnapshot(readObserver = { | |
observations[it] = currentScope |
This file contains 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
val snapshot = Snapshot.takeMutableSnapshot(readObserver = { state -> | |
// called when the state is read | |
}) |
This file contains 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
fun <T> mutableStateOf( | |
value: T, | |
policy: SnapshotMutationPolicy<T> = structuralEqualityPolicy() | |
): MutableState<T> = createSnapshotMutableState(value, policy) | |
class ViewModel { | |
val state = mutableStateOf("init", object : SnapshotMutationPolicy<String> { | |
override fun equivalent(a: String, b: String): Boolean { | |
return a == b |
This file contains 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
val snapshot = Snapshot.takeMutableSnapshot() | |
thread { | |
viewModel.state.value = "changes from other thread" | |
} | |
snapshot.enter { | |
Thread.sleep(100) | |
println("in snapshot before change:" + viewModel.state) | |
viewModel.state.value = "change in snapshot" | |
println("in snapshot after change:" + viewModel.state) | |
} |
This file contains 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
class ViewModel { | |
val state = mutableStateOf("init") | |
} | |
fun main() { | |
val viewModel = ViewModel() | |
viewModel.state.value = "before snapshot" | |
val snapshot = Snapshot.takeMutableSnapshot() |
This file contains 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
// Here is GlobalSnapshot | |
// Create Snapshot | |
val snapshot = Snapshot.takeMutableSnapshot() | |
snapshot.enter { | |
// Recompose here | |
} |