mardi 25 septembre 2018

How to toggle Ember feature flags from the devtools console

I'm using the ember-feature-flags addon to provide some way to toggle new UI features in my ember application.

The docs say that you can toggle these features at runtime:

this.get('features').enable('newHomepage');
this.get('features').disable('newHomepage');

However, this does not work at "runtime" in the devtools console because the this context will refer to the Window object. I do NOT want to rely on the Ember Inspector and the answer to [this existing question] does not work for me: How to access a known Ember component from console (either because the Ember version I'm on does not expose that information or this is a features service, not a component).

I want to be able to do this in native JavaScript, running in the devtools, that can be ported to a simple bookmarklet to give to other folks to toggle the feature flag on and off on their machines.

Ultimately, I think I'm trying to get the Ember application's instance in order to do something similar to what is possible with the Inspector, but instead of doing $E.get('features')..., I would need to do EmberAppInstance.get('features').... I don't know how to get that app instance, though.




Aucun commentaire:

Enregistrer un commentaire