For AI agents: the complete documentation index is available at /llms.txt, the full documentation bundle is available at /llms-full.txt, and this page is available as Markdown at /examples/main-thread.md.

Main-Thread Scripts

Touch handlers that restyle an element on every event, with no Angular re-render in between. Look here before you build drag- or scroll-driven effects.

What it shows

  • mainThreadFn() — wraps a handler as a main-thread script (Glossary) that edits the element directly with setStyleProperty(). See mainThreadFn.
  • [mainThreadBindtap] and [mainThreadBindtouchmove] — bind those handlers to an element's events. Import LynxMainThreadEvent to use them. See LynxMainThreadEvent.
  • createMainThreadRef() — keeps the tap count between calls. See MainThreadRef.
  • backgroundFn() and runOnBackground() — call a function on the background thread (Glossary) from a main-thread script. See backgroundFn.
  • A plain (bindtap) for comparison — the third box updates a signal and lets Angular re-render. Use that for most handlers.