1 | # @ember/optional-features
|
2 |
|
3 | This addon allows you to easily enable/disable optional features in ember-source. To clarify what we mean by optional, these are features that will be opt-in/opt-out and optional for the foreseeable future, not features that will be enabled by default. It is intended for use with apps *only* not addons.
|
4 |
|
5 | ## Installation
|
6 |
|
7 | ```bash
|
8 | ember install @ember/optional-features
|
9 | ```
|
10 |
|
11 | ## Usage
|
12 |
|
13 | ### From command-line
|
14 |
|
15 | #### List available features
|
16 |
|
17 | Features will only be available in versions of ember-source that included them. To list all available features run:
|
18 |
|
19 | ```bash
|
20 | ember feature:list
|
21 | ```
|
22 |
|
23 | #### Enable/disable features
|
24 |
|
25 | To enable a feature, run:
|
26 |
|
27 | ```bash
|
28 | ember feature:enable some-feature
|
29 | ```
|
30 |
|
31 | Similarly, if you want to disable a feature, you can run:
|
32 |
|
33 | ```bash
|
34 | ember feature:disable some-feature
|
35 | ```
|
36 |
|
37 | ### At build-time (from an addon)
|
38 |
|
39 | This addon exposes a build-time method called `isFeatureEnabled`, which can be called from an addon's `index.js`, e.g.:
|
40 |
|
41 | ```javascript
|
42 | included() {
|
43 | let optionalFeatues = this.addons.find(a => a.name === '@ember/optional-features');
|
44 | if (optionalFeatures.isFeatureEnabled('jquery-integration') {
|
45 | // ...
|
46 | }
|
47 | }
|
48 | ```
|
49 |
|
50 | It also exposes a method called `isFeatureExplicitlySet`, which can be used to check whether or not the user has explictly set the value of the option instead of using the default.
|
51 |
|
52 | ### At run-time (from an app or addon)
|
53 |
|
54 | WIP -- there does not yet exist a public API for accessing the state of optional features at runtime. [This](https://github.com/pzuraq/ember-compatibility-helpers/issues/27) issue is tracking it.
|