Skip to main content

system

const

Declare a listener on a host event source. `system.on` builds a value you list in `defineMod`; it does not subscribe by itself. The host owns the subscription for as long as the mod is active. Two neighbours to keep straight. For in-editor facts such as selection changes and committed actions, `ctx.on('editor.selectionChanged', listener)` is typed and simpler. For a subscription whose lifetime you manage yourself, call `ctx.system.on(request, listener)` and dispose it when you are done. Source and event ids come from the host, not from a fixed list in the SDK. Discover them with `ctx.system.listSources()` and `ctx.system.describeSource(source)`.

const system: Readonly<{ on: <TPayload>(input: SystemListenerInput<TPayload>) => SystemListener<TPayload> }>

Import

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

Notes

category
State