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
Iku-turso 2e4aba735f chore: Bump ogre-tools to permit Feature-specific logging prefixes
Co-authored-by: Janne Savolainen <janne.savolainen@live.fi>
Signed-off-by: Iku-turso <mikko.aspiala@gmail.com>
2023-05-17 11:55:05 +03: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
CHANGELOG.md Release 6.5.0-alpha.13 2023-05-16 16:47:36 -04: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 permit Feature-specific logging prefixes 2023-05-17 11:55:05 +03: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