@freelensapp/feature-core
v1.7.0
Published
Code that is common to all Features and those registering them.
Readme
@freelensapp/feature-core
Feature is set of injectables that are registered and deregistered simultaneously.
Install
npm install @freelensapp/feature-coreUsage
import { createContainer } from "@ogre-tools/injectable"
import { getFeature, registerFeature, deregisterFeature } from "@freelensapp/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 exporting
injectionTokeninstead ofinjectablefor not allowing other features to access technical details like theinjectable
