Laboratory (Android)

Library for feature flags management.

License

License

GroupId

GroupId

io.mehow.laboratory
ArtifactId

ArtifactId

laboratory-android
Last Version

Last Version

0.2.0
Release Date

Release Date

Type

Type

aar
Description

Description

Laboratory (Android)
Library for feature flags management.
Project URL

Project URL

https://github.com/MiSikora/Laboratory
Source Code Management

Source Code Management

https://github.com/MiSikora/Laboratory

Download laboratory-android

How to add to project

<!-- https://jarcasting.com/artifacts/io.mehow.laboratory/laboratory-android/ -->
<dependency>
    <groupId>io.mehow.laboratory</groupId>
    <artifactId>laboratory-android</artifactId>
    <version>0.2.0</version>
    <type>aar</type>
</dependency>
// https://jarcasting.com/artifacts/io.mehow.laboratory/laboratory-android/
implementation 'io.mehow.laboratory:laboratory-android:0.2.0'
// https://jarcasting.com/artifacts/io.mehow.laboratory/laboratory-android/
implementation ("io.mehow.laboratory:laboratory-android:0.2.0")
'io.mehow.laboratory:laboratory-android:aar:0.2.0'
<dependency org="io.mehow.laboratory" name="laboratory-android" rev="0.2.0">
  <artifact name="laboratory-android" type="aar" />
</dependency>
@Grapes(
@Grab(group='io.mehow.laboratory', module='laboratory-android', version='0.2.0')
)
libraryDependencies += "io.mehow.laboratory" % "laboratory-android" % "0.2.0"
[io.mehow.laboratory/laboratory-android "0.2.0"]

Dependencies

compile (2)

Group / Artifact Type Version
io.mehow.laboratory : laboratory jar 0.2.0
org.jetbrains.kotlin : kotlin-stdlib-jdk8 jar 1.4.0

runtime (1)

Group / Artifact Type Version
androidx.core » core-ktx jar 1.3.1

Project Modules

There are no modules declared in this project.

Laboratory ⚗️

Quality Check CI Snapshot CI GitHub License

Feature flags for multi-module Kotlin Android projects.

Please visit project website for the full documentation and the changelog.

TLDR

Add Laboratory dependency to your project.

repositories {
  mavenCentral()
}

dependencies {
  implementation "io.mehow.laboratory:laboratory:0.9.7"
}

Enable Java 8 support.

android {
  compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
  }

  kotlinOptions {
    jvmTarget = "1.8"
    freeCompilerArgs += "-Xjvm-default=enable"
  }
}

Define your feature flags.

enum class AuthType : Feature<AuthType> {
  None,
  Fingerprint,
  Retina,
  Face;

  public override val defaultOption get() = Fingerprint
}

Start using them in the application.

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<AuthType>()

  // 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<AuthType>()
      .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 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.

Versions

Version
0.2.0
0.1.0