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 1c48dda707 chore: Bump @ogre-tools/* to 15.3.1 and fixup telemetry decorator
Signed-off-by: Sebastian Malton <sebastian@malton.name>
2023-04-13 11:13:26 -04:00
..
src chore: Upgrade versions of @ogre-tools/* to 15.3.0 2023-04-13 11:13:26 -04: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 chore: Bump @ogre-tools/* to 15.3.1 and fixup telemetry decorator 2023-04-13 11:13:26 -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