Last active
October 26, 2017 16:14
-
-
Save pocmo/5b58631770fe02614098482cb7af0f52 to your computer and use it in GitHub Desktop.
Experiments - Kotlin - Scribble
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// In this scribble the experiments (A/B) library is called "Fretboard" | |
// Experiments.* are not part of the library but constants in the actual app project | |
/////////////////////////////////////////////////////////////////////////// | |
// Simple API (Java style): | |
/////////////////////////////////////////////////////////////////////////// | |
if (Fretboard.isInEperiment(Experiments.BOOKMARKS)) { | |
// do something | |
} | |
val experiment = Fretboard.getExperiment(Experiments.BOOKMARKS) | |
// do something with the experiments object and the data associated with this experiment. | |
/////////////////////////////////////////////////////////////////////////// | |
// More DSL-like API (Kotlin style?) | |
/////////////////////////////////////////////////////////////////////////// | |
Fretboard.withExperiment(Experiments.BOOKMARKS) { | |
// do something | |
// do something with the experiment: | |
System.out.println(it.identifier) | |
System.out.println(it.payload.buttonColor) // Experiments can have additional data attached. | |
} | |
// Or perform the action on the experiment constant: | |
Experiments.BOOKMARKS.ifActive { | |
System.out.println(it.identifier) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment