Skip to content

Instantly share code, notes, and snippets.

@spion
Last active September 25, 2019 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spion/96b6232b151d1007a2aa396c2e2c478a to your computer and use it in GitHub Desktop.
Save spion/96b6232b151d1007a2aa396c2e2c478a to your computer and use it in GitHub Desktop.

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