Skip to content

Commit

Permalink
Add usage sample
Browse files Browse the repository at this point in the history
  • Loading branch information
AChep committed Feb 27, 2021
1 parent 357788f commit 149ae96
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,32 @@ dependencies {
}
```

Usage
----------------
Let's say you have an existing setup with the `LiveData`:
```kotlin
val liveData = MutableLiveData<Boolean>()
liveData.observe(viewLifecycleOwner) {
println(it)
}
```

to migrate it you would have to use the `bindIn` function:
```kotlin
val liveData = MutableLiveData<Boolean>()
viewLifecycleOwner.bindIn(liveData) {
println(it)
}
```

Huh. That looks almost identical, right? The _real benefit_ is that it works for `Flow`s with the exact same syntax!
```kotlin
val flow = MutableStateFlow<Boolean>(false)
viewLifecycleOwner.bindIn(flow) {
println(it)
}
```

Report a bug or request a feature
----------------
Before creating a new issue please make sure that same or similar issue is not already created by checking [open issues][2] and [closed issues][3] *(please note that there might be multiple pages)*. If your issue is already there, don't create a new one, but leave a comment under already existing one.
Expand Down

0 comments on commit 149ae96

Please sign in to comment.