Skip to main content

SystemCapabilities

interface

`ctx.system`: browse the host's event sources and subscribe to them at runtime. Sources are things outside the editor that emit, and which ones exist depends on the host build. Use `listSources()` and `describeSource()` to find the `source` and `event` ids you need, then either subscribe here or declare a listener with `system.on(...)` in `defineMod`. Reach for `on()` here when the subscription starts and stops with something you are doing, since it hands back a `Disposable` you control. A declared listener lives for the whole activation instead.

interface SystemCapabilities

Import

import { SystemCapabilities } from '@modular/sdk';

Members4

describeSource
(source: `system.${string}`) => SystemSourceDescriptorDto | undefined

Look up one source, or `undefined` if the host does not have it.

listSources
() => readonly SystemSourceDescriptorDto[]

Every event source this host build exposes to mods.

on
<TPayload>(request: SystemEventSubscriptionRequest, listener: (event: SystemSourceEvent<TPayload>) => void) => Disposable

Listen to one event of one source. Dispose to stop.

snapshot
(request: SystemSnapshotRequest) => Promise<unknown>

Read a source's current state once, without subscribing.

Notes

category
State