Skip to content

Commit 6d584b7

Browse files
authored
Merge pull request #34 from bendemboski/update-readme
Document API for reading features at build/run-time
2 parents bc02039 + 533d829 commit 6d584b7

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

README.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,17 @@ ember install @ember/optional-features
1010

1111
## Usage
1212

13-
### List available features
13+
### From command-line
14+
15+
#### List available features
1416

1517
Features will only be available in versions of ember-source that included them. To list all available features run:
1618

1719
```bash
1820
ember feature:list
1921
```
2022

21-
### Enable/disable features
23+
#### Enable/disable features
2224

2325
To enable a feature, run:
2426

@@ -31,3 +33,20 @@ Similarly, if you want to disable a feature, you can run:
3133
```bash
3234
ember feature:disable some-feature
3335
```
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+
### At run-time (from an app or addon)
51+
52+
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.

0 commit comments

Comments
 (0)