Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?

Be careful when feature flags affect any shared mutable state. This for example will cause data loss if the flag value changes during the work:

this.fancyModel = FancyModel.createInitial()
this.rustyModel = RustyModel.createInitial()

async loadData() { 
  let flag = await this.ff.isEnabled('flag');
  let data = await this.fetchData();

  if (flag) {
    this.fancyForm.load(data)
  } else {
    this.rustyForm.load(data);
  }
}

async saveData() {
  let flag = await ff.isEnabled('flag');
  if (flag) {
    await post(this.fancyForm.getData());
  } else {
    await post(this.rustyForm.getData())
  }
}

If you are unsure if a flag affects shared mutable data, please grab a snapshot at the top-level of the front end module (e.g. at the page level) being affected by the flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.