Skip to main content

Core Lifecycle Events

These events are emitted by the core kernel during board lifecycle:

board:ready

Emitted once when the board is fully initialized and the API is ready.
FieldTypeDescription
boardElHTMLElementThe board DOM element
api.bus.on('board:ready', ({ boardEl }) => {
  console.log('Board is ready!', boardEl);
});

board:allPluginsLoaded

Emitted after all enabled plugins have been loaded and their setup() called.
FieldTypeDescription
totalnumberTotal plugins in registry
enablednumberNumber of enabled (loaded) plugins
api.bus.on('board:allPluginsLoaded', ({ total, enabled }) => {
  console.log(`${enabled}/${total} plugins loaded`);
});
Use this event for plugins that need to interact with other plugins after they’ve all initialized (e.g., hooks that depend on other plugins being ready).

board:restarted

Emitted after api.restart() completes and all plugins have been reloaded.
api.bus.on('board:restarted', () => {
  console.log('Board was restarted');
});

board:resize

Emitted when the window is resized (debounced at 150ms).
FieldTypeDescription
widthnumberWindow width in pixels
heightnumberWindow height in pixels
api.bus.on('board:resize', ({ width, height }) => {
  console.log(`Resized to ${width}×${height}`);
});

Plugin Lifecycle Events

plugin:loaded

Emitted when a single plugin finishes loading.
FieldTypeDescription
idstringPlugin ID
metaobjectThe plugin’s meta export
containerHTMLElement | nullThe plugin’s container element (if created)
api.bus.on('plugin:loaded', ({ id, meta }) => {
  console.log(`${meta.name} v${meta.version} loaded`);
});

plugin:unload

Emitted when a plugin is toggled off or deleted.
FieldTypeDescription
PayloadstringThe plugin ID being unloaded
api.bus.on('plugin:unload', (pluginId) => {
  if (pluginId === meta.id) myElement.remove();
});

plugin:unloaded

Emitted after a plugin has been fully torn down and its container removed.
FieldTypeDescription
PayloadstringThe plugin ID that was unloaded

Container & Docking Events

plugin:docked

Emitted when a plugin container is docked into a target element.
FieldTypeDescription
pluginIdstringPlugin ID
elHTMLElementThe plugin’s container element
targetHTMLElementThe target element the plugin was docked into

plugin:undocked

Emitted when a plugin container is undocked and becomes floating.
FieldTypeDescription
pluginIdstringPlugin ID
elHTMLElementThe plugin’s container element

plugin:updated

Emitted after api.updatePlugin() modifies a plugin’s container.
FieldTypeDescription
pluginIdstringPlugin ID
elHTMLElementThe plugin’s container element

Drag Events

plugin:dragstart

Emitted when a plugin container starts being dragged.
FieldTypeDescription
elHTMLElementThe element being dragged

plugin:dragend

Emitted when a plugin container stops being dragged.
FieldTypeDescription
elHTMLElementThe element that was dragged
api.bus.on('plugin:dragend', ({ el }) => {
  if (el.dataset.pluginId === meta.id) {
    // Save position
    api.storage.set('my-pos', {
      left: parseInt(el.style.left),
      top: parseInt(el.style.top)
    });
  }
});

UI Events

contextmenu:open

Emitted when the board context menu (right-click) opens.
FieldTypeDescription
xnumberMouse X position
ynumberMouse Y position
menuHTMLElementThe context menu DOM element

Storage Events

storage:change

Emitted whenever a value is stored via api.storage.set() or api.storage.setForPlugin().
FieldTypeDescription
keystringThe storage key
valueanyThe new value
oldValueanyThe previous value
pluginIdstring(only for setForPlugin) The plugin that stored the value
api.bus.on('storage:change', ({ key, value, oldValue }) => {
  if (key === 'my-plugin-theme') {
    console.log(`Theme changed from ${oldValue} to ${value}`);
  }
});

Plugin-Specific Events

Plugins can define and emit their own events freely. Use namespace:action naming:
PluginEventPayload
Sticky Notesticky-note:created{ id: string }
Sticky Notesticky-note:deleted{ id: string }
Clockclock:tick{ hours, minutes, seconds, date }

window.blankBoard

After boot, the core exposes a global debug object:
// In browser DevTools:
window.blankBoard.bus.emit('test', { hello: true });
window.blankBoard.api.registry.getAll();
window.blankBoard.api.installPlugin('debug', './debug.js', 'Debug');
window.blankBoard.api.version;  // → "4.0.0"
window.blankBoard is only available for debugging. Plugins should use the api object passed to setup().