Skip to content

Binder context

The binder context provides the binder instance to all components. This context is provided by the output component.

const BinderContext: ComponentContext<Binder>

Accessor

import { useBinder } from "@alloy-js/core";
const myContext = useBinder();

Context interface

addInstanceMembersToSymbol(OutputSymbol) => void

Add instance members to an existing symbol.

addStaticMembersToSymbol(OutputSymbol) => void

Add static members to an existing symbol.

createScope(CreateScopeOptions<T>) => T

Create a new scope. The scope will be added to the parent scope’s children. The returned scope object is reactive.

createSymbol(CreateSymbolOptions<T>) => T

Create a new symbol. The symbol will be added to the parent scope’s symbols. The returned symbol object is reactive.

deleteSymbol(OutputSymbol) => void

Delete the given symbol. The symbol will be removed from its parent’s scope. Any resolutions to this symbol will become undefined.

findScopeName(TScope | undefined, string) => Ref<TScope | undefined>
findSymbolName(TScope | undefined, string) => Ref<TSymbol | undefined>

Find a symbol with a given name in the given scope. Returns a ref for the symbol, such that when the symbol is available, the ref value will update.

getSymbolForRefkey(Refkey) => Ref<TSymbol | undefined>
globalScopeScope context interface

The global scope. This is the root scope for all symbols.

instantiateSymbolInto(OutputSymbol, OutputSymbol) => void

Instantiate the static members of a symbol into the instance members of another symbol.

resolveDeclarationByKey(TScope | undefined, TScope | undefined, Refkey) => Ref<ResolutionResult<TScope, TSymbol> | undefined>

Resolve the given refkey in the current scope.

resolveFQN(string) => Ref<TSymbol | TScope | undefined>

Resolve a fully qualified name to a symbol. Access a nested scope by name with ::, a nested static member with . and a nested instance member with #.

Per-language packages may provide their own resolveFQN function that uses syntax more natural to that language.