PluginManager
This class is usually the main part of the application.
Constructor Summary
Public Constructor | ||
public |
constructor(options: Object) Create a new instance. |
Member Summary
Public Members | ||
public get |
Get the current application context. |
|
public get |
Determine if running in debug mode. |
|
public get |
Get logger. |
Method Summary
Public Methods | ||
public |
addHandler(eventName: String, handler: Function): Object Adds a new handler to the event list. |
|
public |
addPlugins(plugins: Object[]): PluginManager Add local plugins. |
|
public |
Helper method to dispatch events. |
|
public |
getMaxHandlers(): Integer Get max event handlers. |
|
public |
Get list of handlers for an event. |
|
public |
hasHandler(event: String, handler: Function | String): Boolean Determines if a handler exists for an event. |
|
public |
hasHandlers(event: String): Boolean Determines if an event has any handlers. |
|
public |
init(plugin: Object, npm: Object): PluginManager Initialize the application. |
|
public |
removeAllHandlers(eventName: String): Object Deletes all handlers for an event. |
|
public |
removeHandler(eventName: String, handler: Function | String): PluginManager Removes a handler for an event that matches the handler function name. |
|
public |
setMaxHandlers(count: Integer): Object Set max number of event handlers. |
Public Constructors
public constructor(options: Object) source
Create a new instance.
Params:
Name | Type | Attribute | Description |
options | Object |
|
options object |
options.debug | Boolean |
|
debug flag |
options.context | String |
|
context name |
options.configFile | String |
|
set the config file path |
options.override | Boolean |
|
whether to override matching functions |
Public Members
Public Methods
public addHandler(eventName: String, handler: Function): Object source
Adds a new handler to the event list.
public dispatch(eventName: String, context: Object): Object source
Helper method to dispatch events.
public getMaxHandlers(): Integer source
Get max event handlers.
Return:
Integer | max number of handlers |
public handlers(eventName: String): Function[] source
Get list of handlers for an event.
Params:
Name | Type | Attribute | Description |
eventName | String | the event name |
public hasHandler(event: String, handler: Function | String): Boolean source
Determines if a handler exists for an event.
public hasHandlers(event: String): Boolean source
Determines if an event has any handlers.
Params:
Name | Type | Attribute | Description |
event | String | the event name |
public init(plugin: Object, npm: Object): PluginManager source
Initialize the application.
Generates config file if it does not exist and loads plugins.
public removeAllHandlers(eventName: String): Object source
Deletes all handlers for an event.
Params:
Name | Type | Attribute | Description |
eventName | String | the event name to removes |
public removeHandler(eventName: String, handler: Function | String): PluginManager source
Removes a handler for an event that matches the handler function name.