Skip to main content
Version: 1.x


Type: class

The Registry class represents a collection of id and value pairs known as records. Each id is a string that identifies a value (which can be anything, including another Registry which we then call a subregistry). Each id is unique so it can only be registered once, unless it is deregistered and registered again.

  • Registries are an integral part of the Vime plugin system.
  • If a registry is created within a Plugin (aka Svelte component), it will automatically destroy itself when the component does.
  • If a registered value is a Svelte component, it will automatically be deregistered when the component is destroyed. :::


Constructor: new Registry(id: string, validator: ((id: string, value: any) => boolean)?)

import { Registry } from '@vime-js/complete';
const id = 'myRegistry';
* Values are not registered if they fail validation. This
* should log a message so developers are aware of why a
* particular registration failed.
const optionalValidator = (id, value) => true;
const registry = new Registry(id, optionalValidator);
// ...
// No need to call this if we are inside a Plugin (aka Svelte component).


A registry is powered by a store. Thus, you can subscribe to the Registry and be updated of any changes to its records.

const registry = new Registry('myRegistry');
registry.subscribe(records => {



Return Type: string

The id the registry was created with.


Return Type: string

The name of the registry, which is simply {id}Registry. This is used for logging errors.


Return Type: string[]

A list of all registered id's.


Parameters: (id: string) | Return Type: string[]

Gets the currently registered value for the given id.


Return Type: any[]

A list of all registered values.


Parameters: (id: string) | Return Type: boolean

Checks whether any value is registered to the given id.


Notifies the registry to send a new copy of it's records to subscribers. Bubbles up to parent registries.


Parameters: (id: string, value: any)

Registers a value under the given id. This method throws if there is no id or if it is taken.


Parameters: (id: string)

Deregisters the given id and removes its corresponding value.


Return Type: ReadonlyStore<object>

A readonly store that emits updated copies of all records. All subregistries are unwrapped to return their records.


Deregisters all registrations, and if it is a subregistry it deregisters itself from its parent.


Events are only emitted if the registry is created within a Plugin (aka Svelte component). The event is emitted using the components event dispatcher.


Data Type: { id: string, value: any }

Fires on new registrations.


Data Type: string (The id of the deregistered value)

Fires on deregistrations.