Extending Albert
This page provides an overview of general concepts. For details of any particular interface refer to the respective page.
Plugins and extensions
The core of a plugin is the PluginInstance
class. It is the interface that every Albert plugin must implement. The loader of a plugin resolves and instantiates the concrete implementation of this class. It serves as settings widget and extension factory and provides utility functions for plugins.
Extension
is the polymorphic base class of any kind of extension. Built on this type the extension system provides an ExtensionRegistry
. Plugins can implement existing extension interfaces to provide additional functionality, but also define their own types of extensions and listen for registrations of instances thereof.
Related classes:
-
ExtensionPlugin
: Implements theExtension
interface using the metadata of the plugin instance. -
StrongDependency
Fetches and holds a reference to a mandatory dependency. -
WeakDependency
Fetches and holds a reference to an optional dependency.
The core application offers a set of built-in interfaces that plugins can implement. The current core app extension interfaces are:
Query handlers
The basic query handling extension are:
If you’ve read the basics their purpose should be clear. All of them provide instances of the Item
interface. The Item
interface provides several methods related to the features of the user interface, most notably the Action
factory.
The GlobalQueryHandler
implements the TriggerQueryHandler
interface. This is a design decision to simplify the plugin development.
The IndexQueryHandler
implements the GlobalQueryHandler
interface. It serves as a convenience class that performs (fuzzy) matching using a 2-gram index.
Related classes:
-
Query
Represents a query execution. -
StandardItem
Value-based implementation of theItem
interface. -
RankItem
Used byGlobalQueryHandler
to return scored matches. -
IndexItem
Used byIndexQueryHandler
to associate an item with a lookup string. -
Matcher
Utility for configurable string matching.