-
Notifications
You must be signed in to change notification settings - Fork 0
Unit: Component
Jake edited this page Jul 20, 2018
·
2 revisions
Components perform a specific interaction for a plugin. This could be handling one http request, managing a singular websocket connection, or reacting to a key press from a midi keyboard.
A valid component unit conforms to this interface:
interface ComponentUnit {
is: 'component';
type: string | string[];
config?: {
dependencies?: {
plugins?: string[];
services?: string[];
}
[key: string]: any;
}
[key: string]: any;
}
Often, a component will need to offer an entry point to perform some action. This is taken care of by a method with the same name as the component's type. For example, when creating a HTTP component, you may add a http()
method for handling a request:
const component = {
is: 'component',
type: 'http',
http (request, response) {
// ...
}
}