https://github.com/zhuinden/flow-validateby-kt
[ACTIVE] Helper function for Flow, to combine multiple boolean values into a single boolean.
https://github.com/zhuinden/flow-validateby-kt
Last synced: 8 months ago
JSON representation
[ACTIVE] Helper function for Flow, to combine multiple boolean values into a single boolean.
- Host: GitHub
- URL: https://github.com/zhuinden/flow-validateby-kt
- Owner: Zhuinden
- License: apache-2.0
- Created: 2020-09-18T09:14:02.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-08-26T14:26:09.000Z (over 4 years ago)
- Last Synced: 2024-10-26T21:34:52.884Z (about 1 year ago)
- Language: Kotlin
- Size: 112 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Flow-ValidateBy-KT
Flow-ValidateBy-KT contains helper functions for Flow, to combine the emissions of boolean flows into a single boolean.
``` kotlin
validateBy(booleanFlow1, booleanFlow2, booleanFlow3)
.collect { isEnabled ->
// do something with combined boolean value
}
```
## Why?
It's useful when you want to combine multiple boolean streams together and get a single combined boolean.
## Using Flow-ValidateBy-KT
In order to use Flow-ValidateBy-KT, you need to add `jitpack` to your project root `build.gradle.kts`
(or `build.gradle`):
``` kotlin
// build.gradle.kts
allprojects {
repositories {
// ...
maven { setUrl("https://jitpack.io") }
}
// ...
}
```
or
``` groovy
// build.gradle
allprojects {
repositories {
// ...
maven { url "https://jitpack.io" }
}
// ...
}
```
In newer projects, you need to also update the `settings.gradle` file's `dependencyResolutionManagement` block:
```
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
maven { url 'https://jitpack.io' } // <--
jcenter() // Warning: this repository is going to shut down soon
}
}
```
and then, add the dependency to your module's `build.gradle.kts` (or `build.gradle`):
``` kotlin
// build.gradle.kts
implementation("com.github.Zhuinden:flow-validateby-kt:2.1.1")
```
or
``` groovy
// build.gradle
implementation 'com.github.Zhuinden:flow-validateby-kt:2.1.1'
```
## License
Copyright 2020 Gabor Varadi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.