Cleanup and progress
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
export abstract class EventEmitter<HandlerT> {
|
||||
private handlers: Partial<HandlerT>[] = [];
|
||||
|
||||
on(handlers: Partial<HandlerT>) {
|
||||
this.handlers.push(handlers);
|
||||
}
|
||||
|
||||
off(handlers: Partial<HandlerT>) {
|
||||
this.handlers = this.handlers.filter((h) => h !== handlers);
|
||||
}
|
||||
|
||||
emit(eventName: keyof HandlerT, ...args: any[]) {
|
||||
for (let handler of this.handlers) {
|
||||
let fn: any = handler[eventName];
|
||||
if (fn) {
|
||||
fn(...args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import * as plugbox from "../plugbox/types";
|
||||
import { EndpointHook } from "../plugbox/types";
|
||||
|
||||
export type CommandDef = {
|
||||
// Function name to invoke
|
||||
invoke: string;
|
||||
|
||||
// Bind to keyboard shortcut
|
||||
key?: string;
|
||||
mac?: string;
|
||||
|
||||
// If to show in slash invoked menu and if so, with what label
|
||||
// should match slashCommandRegexp
|
||||
slashCommand?: string;
|
||||
};
|
||||
|
||||
export type SilverBulletHooks = {
|
||||
commands?: {
|
||||
[key: string]: CommandDef;
|
||||
};
|
||||
} & plugbox.EndpointHook;
|
||||
|
||||
export type Manifest = plugbox.Manifest<SilverBulletHooks>;
|
||||
Reference in New Issue
Block a user