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
Sebastian Malton 3649070ca3
Release 6.5.0-alpha.1 (#7345)
* Release 6.5.0-alpha.1

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Switch to having lerna in independent mode

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Fix package versions

Signed-off-by: Sebastian Malton <sebastian@malton.name>

* Update snapshot

Signed-off-by: Sebastian Malton <sebastian@malton.name>

---------

Signed-off-by: Sebastian Malton <sebastian@malton.name>
2023-03-14 11:40:35 -04:00
..
src Introduce eslint and prettier for features and start using it (#7306) 2023-03-10 12:25:04 +02:00
.eslintrc.js Introduce eslint and prettier for features and start using it (#7306) 2023-03-10 12:25:04 +02:00
.prettierrc Introduce eslint and prettier for features and start using it (#7306) 2023-03-10 12:25:04 +02:00
index.ts Introduce package for Features (#7242) 2023-02-28 08:37:07 -05:00
jest.config.js Introduce eslint and prettier for features and start using it (#7306) 2023-03-10 12:25:04 +02:00
package.json Release 6.5.0-alpha.1 (#7345) 2023-03-14 11:40:35 -04:00
README.md Introduce package for Features (#7242) 2023-02-28 08:37:07 -05:00
tsconfig.json Introduce eslint and prettier for features and start using it (#7306) 2023-03-10 12:25:04 +02:00
webpack.config.js Introduce package for Features (#7242) 2023-02-28 08:37:07 -05:00

@k8slens/feature-core

Feature is set of injectables that are registered and deregistered simultaneously.

Install

$ npm install @k8slens/feature-core

Usage

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