Skip to content

GadgetRegistry

Defined in: gadgets/registry.ts:10

new GadgetRegistry(): GadgetRegistry

GadgetRegistry

clear(): void

Defined in: gadgets/registry.ts:119

void


get(name): AbstractGadget | undefined

Defined in: gadgets/registry.ts:94

string

AbstractGadget | undefined


getAll(): AbstractGadget[]

Defined in: gadgets/registry.ts:109

AbstractGadget[]


getNames(): string[]

Defined in: gadgets/registry.ts:104

string[]


has(name): boolean

Defined in: gadgets/registry.ts:99

string

boolean


register(name, gadget): void

Defined in: gadgets/registry.ts:73

string

AbstractGadget

void


registerByClass(gadget): void

Defined in: gadgets/registry.ts:88

AbstractGadget

void


registerMany(gadgets): this

Defined in: gadgets/registry.ts:64

Registers multiple gadgets at once from an array.

GadgetOrClass[]

Array of gadget instances or classes

this

This registry for chaining

registry.registerMany([Calculator, Weather, Email]);
registry.registerMany([new Calculator(), new Weather()]);

unregister(name): boolean

Defined in: gadgets/registry.ts:114

string

boolean


static from(gadgets): GadgetRegistry

Defined in: gadgets/registry.ts:35

Creates a registry from an array of gadget classes or instances, or an object mapping names to gadgets.

Array of gadgets/classes or object with custom names

Record<string, GadgetOrClass> | GadgetOrClass[]

GadgetRegistry

New GadgetRegistry with all gadgets registered

// From array of classes
const registry = GadgetRegistry.from([Calculator, Weather]);
// From array of instances
const registry = GadgetRegistry.from([new Calculator(), new Weather()]);
// From object with custom names
const registry = GadgetRegistry.from({
calc: Calculator,
weather: new Weather({ apiKey: "..." })
});