Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose a module for runtime detection of opt-in/opt-out. #10

Open
rwjblue opened this issue Feb 10, 2018 · 5 comments
Open

Expose a module for runtime detection of opt-in/opt-out. #10

rwjblue opened this issue Feb 10, 2018 · 5 comments

Comments

@rwjblue
Copy link
Member

rwjblue commented Feb 10, 2018

At times, addons will need to know if specific optional features are enabled or not. With the current architecture it is only possible to detect at runtime via window.EmberENV._SOME_FLAG_HERE, but we should not encourage that type of coupling to EmberENV.

As I see it we have a few options:

  • Provide a @ember/optional-features module that can be imported and checked for various opt-in's. This would allow consumers to use an import and conditionals in their code based on a given optional flag value.
  • Expose a custom babel plugin that can be used when an addon includes @ember/optional-features as a direct dependency. This babel plugin would provide custom build time replacement of @ember/optional-features based conditionals, and would therefore allow addons to include support for multiple variations of features without bloating the total asset size.
@rwjblue
Copy link
Member Author

rwjblue commented Feb 10, 2018

@chancancode - Thoughts?

@rwjblue
Copy link
Member Author

rwjblue commented Feb 10, 2018

Oh, also, IMHO we should do both options...

@bendemboski
Copy link
Contributor

This should probably also expose whether the user explicitly opted in/out (as opposed to simply accepting the default), so it can be used to address emberjs/ember.js#16849.

@rwjblue
Copy link
Member Author

rwjblue commented Sep 17, 2018

Ya, agreed, though I think that it may need to be a separate API. I think most of the time you just want to know enabled or disabled, but in a somewhat rare set of cases you care if the user explicitly chose the setting or not...

@Gaurav0
Copy link

Gaurav0 commented Mar 5, 2020

As there has been no movement on this, Ember Twiddle will be using EmberENV as an intimate api.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants