Skip to main content

ConditionContext

interface

What a predicate is allowed to look at. Reads only. `state()` here returns a read-only State even for your own declarations, unlike `ctx.state()` in a handler, which hands back a writable owned handle. Reading a value registers it as a dependency, which is how the host knows when to recompute.

interface ConditionContext

Import

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

Members3

condition()
(condition: Condition) => boolean

Evaluate another condition, so rules can build on each other.

lastEvent()
<K extends ModularEventId>(id: K) => ModularEventMap[K] | null | <TValue = unknown>(id: HostEventId) => TValue | null

The payload of the last occurrence of an event, or `null` if none yet.

state()
<TValue>(declaration: StateDeclaration<TValue>) => State<TValue> | <TName extends BuiltInStateName>(name: TName) => State<BuiltInStateValue<TName>>

Read your own declared state. Read built-in host state, such as `'editor.selection'`.