Skip to content

ViewRegistry

Unofficial

Registry that maps view types to their constructors and file extensions to view types.

Import:

import type { ViewRegistry } from '@obsidian-typings/obsidian-catalyst-latest';

Signature:

export interface ViewRegistry extends Events

Extends: Events

Constructor

new ViewRegistry()

Constructor.

To get the constructor instance, use getViewRegistryConstructor from obsidian-typings/implementations.

Properties

PropertyTypeDescription
_Record<string, EventsEntry[]>Internal storage of registered event handlers by event name.
(Inherited from Events)
typeByExtensionViewRegistryTypeByExtensionRecordMapping of file extensions to view type.
viewByTypeViewRegistryViewByTypeRecordMapping of view type to view constructor.

Methods

MethodReturnsDescription
getTypeByExtension(extension)string | undefinedGet the view type associated with a file extension.
getViewCreatorByType(type)undefined | ViewCreatorGet the view creator function associated with a view type.
getViewCreatorByType(type)TypedViewCreator<ViewTypeViewMapping[TViewType]> | undefinedGet the view constructor associated with a view type.
isExtensionRegistered(extension)booleanCheck whether a view type is registered.
off(name, callback)voidRemove an event listener.
(Inherited from Events)
offref(ref)voidRemove an event listener by reference.
(Inherited from Events)
on('extensions-updated', callback)EventRefCalled when the file extensions mapping has been updated.
on('view-registered', callback)EventRefCalled when a view of type has been registered into the registry.
on('view-unregistered', callback)EventRefCalled when a view of type has been unregistered from the registry.
on(name, callback, ctx?)EventRefAdd an event listener.
(Inherited from Events)
registerExtensions(extensions, viewType)voidRegister a view type for file extensions.
registerView(type, viewCreator)voidRegister a view constructor for a view type.
registerViewWithExtensions(extensions, type, viewCreator)voidRegister a view and its associated file extensions.
trigger(name, data?)voidTrigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from Events)
tryTrigger(evt, args)voidTry to trigger an event, executing all the listeners in order even if some of them throw an error.
(Inherited from Events)
unregisterExtensions(extensions)voidUnregister extensions for a view type.
unregisterView(type)voidUnregister a view type.

Links to this page: