Skip to content

Commit a8ce4b1

Browse files
docs: regenerate llms.txt and llms-full.txt
1 parent 6db442e commit a8ce4b1

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

docs/llms-full.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9638,6 +9638,40 @@ dependencies {
96389638

96399639
## Usage
96409640

9641+
### Manual usage
9642+
9643+
This is the core functionality - it’s totally up to you how you want to use it. Just don’t forget to dispose its callback (`removeListener`) when you don’t need it anymore.
9644+
9645+
You can use Compose states, RxJava/Kotlin, or anything else you prefer.
9646+
9647+
Here we’re using a coroutines Flow wrapper just for demonstration.
9648+
9649+
```kt
9650+
val isSystemDarkFlow: Flow<Boolean> = callbackFlow<Boolean> {
9651+
val listener: Consumer<Boolean> = { isDark: Boolean ->
9652+
trySend(isDark)
9653+
}
9654+
9655+
val darkModeDetector = getPlatformDarkModeDetector()
9656+
9657+
// emit initial value
9658+
trySend(darkModeDetector.isDark())
9659+
9660+
// listen to dark mode change events
9661+
darkModeDetector.registerListener(listener)
9662+
awaitClose {
9663+
darkModeDetector.removeListener(listener)
9664+
}
9665+
}
9666+
isSystemDarkFlow.collect {
9667+
println("dark mode changes, isDark: $it")
9668+
}
9669+
```
9670+
9671+
### In compose
9672+
9673+
There is already a composable function available out of the box, which you can use it in your compose applications.
9674+
96419675
```kotlin
96429676
@Composable
96439677
fun App() {

0 commit comments

Comments
 (0)