not-yet
v1.0.7
Published
An angular library to add feature toggle functionality to your project/s and will toggle elements/components on or off based on a feature list provided.
Downloads
23
Maintainers
Readme
NotYet
An angular library to add feature toggle functionality to your project/s and will toggle elements/components on or off based on a feature list provided.
This library was generated with Angular CLI version 15.0.0.
Installation :wrench:
npm install not-yet
The installation has a post install script which should create the file not-yet-features.json
in the src/assets/
directory. This is because
Angular already includes all files in the assets directory when building so no configuration is required to include the file.
Confirm that the file is created in src/assets/, and if the file is missing after installation please add it or follow the instructions on how to use a custom file below.
:warning: Note: Please don't forget to import the module NotYetModule
, in the appropriate module when using in an Angular project.
Usage :man_mechanic:
- Add the not-yet directive with the release version as a string, to the component/s or element/s that you wish to disable until a particular release.
<div *notYet="'19.9.2'" >
<h2>The new feature</h2>
</div>
- Then when the feature needs to be accessed, add the version number/s in the list of 'featuresReleased' in the
not-yet-features.json
file.
"featuresReleased": ["19.9.2", "19.9.3"]
Using a custom file (override) :toolbox:
You can specify a custom json file instead of the not-yet-features.json
to store the list of features, either locally in the assest folder of the project or as a hosted file.
:warning: Note: The custom file must be a json file and must have the following format:
{
"featuresReleased":[]
}
Override with a local json file :file_cabinet:
- Create a json file e.g features.json, make sure to place it somewhere in the assets folder. In the example below the file is placed in src/assets/configuration/ .
src
|-- app
|-- assets
|-- configuration
|-- features.json
- Then you will need to provide a new value for the token NOT_YET_FILE_PATH in the app.module .
import { NOT_YET_FILE_PATH, NotYetModule } from 'not-yet';
providers: [
{
provide: NOT_YET_FILE_PATH,
useValue: "./assets/configuration/features.json"
}
],
Override with a hosted json file :cloud:
When using a hosted json file, all that needs to be done after making the file accessible, is to provide the address to the file. The example specifies a URL to a json file on GitHub.
import { NOT_YET_FILE_PATH, NotYetModule } from 'not-yet';
providers: [
{
provide: NOT_YET_FILE_PATH,
useValue: "https://raw.githubusercontent.com/themegat/store/main/features.json"
}
],
:warning: Note: Make sure that the file has the correct format specifiying the featuresReleased list.
Examples :desktop_computer:
If you need a live example, please visit: https://stackblitz.com/edit/github-pgpsgp?file=README.md