Anchor node example

Sample app for the anchor node pattern

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 inputFields and outputFields in its descriptor.
  • BrightScript drives the component through those inputs (for example, changeVisibility and assignFocus).
  • 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:

  • ViewOne and ViewTwo: two independent anchor nodes registered from index.ts
  • Boolean inputs that control visibility and focus from BrightScript
  • An Object output 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 sources

Did this page help you?