1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00
lens/packages/technical-features/feature-core/README.md
Janne Savolainen c174965708
Introduce package for Features (#7242)
Signed-off-by: Janne Savolainen <janne.savolainen@live.fi>
2023-02-28 08:37:07 -05:00

42 lines
1.1 KiB
Markdown

# @k8slens/feature-core
Feature is set of injectables that are registered and deregistered simultaneously.
## Install
```bash
$ npm install @k8slens/feature-core
```
## Usage
```typescript
import { createContainer } from "@ogre-tools/injectable"
import { getFeature, registerFeature, deregisterFeature } from "@k8slens/feature-core"
// Notice that this Feature is usually exported from another NPM package.
const someFeature = getFeature({
id: "some-feature",
register: (di) => {
di.register(someInjectable, someOtherInjectable);
},
// Feature dependencies are automatically registered and
// deregistered when necessary.
dependencies: [someOtherFeature]
});
const di = createContainer("some-container");
registerFeature(di, someFeature);
// Or perhaps you want to deregister?
deregisterFeature(di, someFeature);
```
## Need to know
#### NPM packages exporting a Feature
- Prefer `peerDependencies` since they are installed from the application and are not allowed to be in the built bundle.
- Prefer exporting `injectionToken` instead of `injectable` for not allowing other features to access technical details like the `injectable`