Anchor node example
This RSG 2.0 SDK app demonstrates how TypeScript components are exposed to BrightScript as anchor nodes via defineAnchorNode and registerAnchorNode.
Purpose
This app shows the anchor node contract:
- A TypeScript component declares typed
inputFieldsandoutputFieldsin its descriptor. - BrightScript drives the component through those inputs (for example,
changeVisibilityandassignFocus). - The TypeScript side pushes data back through outputs (for example,
sendData). - Multiple anchor nodes share plain module state (
global-count.ts).
Summary
This example covers the following topics:
ViewOneandViewTwo: two independent anchor nodes registered fromindex.ts- Boolean inputs that control visibility and focus from BrightScript
- An
Objectoutput field that emits data back to BrightScript on a button press - Shared mutable module state that both views read and write
Development
You can use these commands to build, test, and lint the example.
npx rk dev # Build + deploy to Roku device
pnpm test # Run tests
pnpm run lint # Lint sourcesUpdated about 6 hours ago
Did this page help you?