feat(mobx): add experiments store

This commit is contained in:
Paul
2021-12-11 13:23:01 +00:00
parent 835609dbbd
commit fa009c43e3
4 changed files with 33 additions and 31 deletions

View File

@@ -10,7 +10,7 @@ export type Experiment = "dummy" | "theme_shop";
/**
* Currently active experiments.
*/
export const AVAILABLE_EXPERIMENTS: Experiment[] = ["theme_shop"];
export const AVAILABLE_EXPERIMENTS: Experiment[] = ["dummy", "theme_shop"];
/**
* Definitions for experiments listed by {@link Experiment}.
@@ -84,6 +84,19 @@ export default class Experiments implements Persistent<Data> {
this.enabled.delete(experiment);
}
/**
* Set the state of an experiment.
* @param key Experiment
* @param enabled Whether this experiment is enabled.
*/
@computed setEnabled(key: Experiment, enabled: boolean): void {
if (enabled) {
this.enable(key);
} else {
this.disable(key);
}
}
/**
* Reset and disable all experiments.
*/