Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/misikora/laboratory
Feature flags for multi-module Kotlin Android projects
https://github.com/misikora/laboratory
ab-testing abc-testing android android-development code-generation feature-flags gradle-plugin jetpack-android jetpack-datastore kotlin kotlin-android laboratory
Last synced: 26 days ago
JSON representation
Feature flags for multi-module Kotlin Android projects
- Host: GitHub
- URL: https://github.com/misikora/laboratory
- Owner: MiSikora
- License: apache-2.0
- Created: 2020-06-09T14:21:51.000Z (over 4 years ago)
- Default Branch: trunk
- Last Pushed: 2024-10-01T11:41:22.000Z (about 1 month ago)
- Last Synced: 2024-10-13T04:21:40.651Z (26 days ago)
- Topics: ab-testing, abc-testing, android, android-development, code-generation, feature-flags, gradle-plugin, jetpack-android, jetpack-datastore, kotlin, kotlin-android, laboratory
- Language: Kotlin
- Homepage: https://mehow.io/laboratory/
- Size: 3.27 MB
- Stars: 82
- Watchers: 3
- Forks: 3
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# Laboratory ⚗️
[](https://search.maven.org/search?q=g:io.mehow.laboratory)
[](https://oss.sonatype.org/content/repositories/snapshots/io/mehow/laboratory/)Feature flags for multi-module Kotlin Android projects.
Please visit [project website](https://mehow.io/laboratory/) for the full documentation and the [changelog](https://mehow.io/laboratory/changelog/).
## TLDR
Add Laboratory dependency to your project.
```groovy
repositories {
mavenCentral()
}dependencies {
implementation "io.mehow.laboratory:laboratory:1.1.0"
}
```Enable [default methods generation](https://blog.jetbrains.com/kotlin/2020/07/kotlin-1-4-m3-generating-default-methods-in-interfaces/).
```groovy
android {
kotlinOptions {
freeCompilerArgs += [
"-Xjvm-default=all",
]
}
}
```Define your feature flags.
```kotlin
enum class AuthType : Feature {
None,
Fingerprint,
Retina,
Face;public override val defaultOption get() = Fingerprint
}
```Start using them in the application.
```kotlin
suspend fun main() {
// A high-level API for interaction with feature flags
val laboratory = Laboratory.inMemory()// Set AuthType option to Fingerprint
val success = laboratory.setOption(AuthType.Fingerprint)// Check what is the current option of AuthType
val currentAuthType = laboratory.experiment()// Check if the current option of AuthType is equal to Face
val isFaceAuth = laboratory.experimentIs(AuthType.Face)// Observe changes to the AuthType feature flag
laboratory.observe()
.onEach { option -> println("AuthType: $option") }
.launchIn(GlobalScope)
}
```## License
Copyright 2020 Michał Sikora
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 athttp://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.