Created
April 23, 2023 08:51
-
-
Save thearchetypee/1e651aa9b11378db9f728bf4f1d32e02 to your computer and use it in GitHub Desktop.
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 MyComponent() { | |
var data by remember { mutableStateOf("") } | |
val disposableEffect = remember { mutableStateOf<Disposable?>(null) } | |
DisposableEffect(Unit) { | |
val disposable = someAsyncOperation().subscribe { | |
data = it | |
} | |
onDispose { | |
disposable.dispose() | |
} | |
disposableEffect.value = disposable | |
} | |
// rest of the composable function | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment