npm.io
7.0.3 • Published 2 months ago

@villedemontreal/workit-core

Licence
MIT
Version
7.0.3
Deps
8
Size
58 kB
Vulns
1
Weekly
0
Stars
62

WorkIt Core

License: MIT

This package provides default and no-op implementations of the WorkIt types for client packages.

npm i @villedemontreal/workit-core

Plugin System

WorkIt Core includes a powerful plugin system that allows you to extend worker functionality without modifying the core code. Plugins use dependency injection for seamless integration.

Key Features

  • Extensible architecture - Add custom functionality through plugins
  • Dynamic loading - Enable/disable plugins at runtime
  • IoC integration - Full access to the dependency injection container
  • Lifecycle management - Automatic plugin loading/unloading
  • Configuration support - Flexible plugin configuration
Quick Example
// Create a custom plugin
export class MyPlugin extends BasePlugin {
  public readonly moduleName = 'my-plugin';
  
  protected bind(): void {
    // Register your services in the IoC container
    this._ioc.bindTo(MyService, 'myService', new MyService());
  }
  
  protected unbind(): void {
    this._ioc.unbind('myService');
  }
}

// Configure and load plugins
const plugins: IPlugins = {
  'my-plugin': {
    enabled: true,
    path: './my-plugin'
  }
};

const pluginLoader = new PluginLoader(IoC, logger);
pluginLoader.load(plugins);
Documentation & Examples

Keywords