MCPcopy Create free account
hub / github.com/TanStack/ai / applyUIUpdates

Function applyUIUpdates

examples/ts-code-mode-web/src/lib/reports/apply-event.ts:123–145  ·  view source on GitHub ↗
(
  state: ReportState,
  updates: UIUpdate[],
)

Source from the content-addressed store, hash-verified

121 * Apply handler-driven UI updates to a ReportState.
122 */
123export function applyUIUpdates(
124 state: ReportState,
125 updates: UIUpdate[],
126): ReportState {
127 let nextState = state
128
129 for (const update of updates) {
130 if (update.type === 'update') {
131 nextState = applyUIEvent(nextState, {
132 op: 'update',
133 id: update.componentId,
134 props: update.props ?? {},
135 })
136 } else if (update.type === 'remove') {
137 nextState = applyUIEvent(nextState, {
138 op: 'remove',
139 id: update.componentId,
140 })
141 }
142 }
143
144 return nextState
145}
146
147/**
148 * Apply refresh results from subscription invalidation.

Callers 3

BankingDemoPageFunction · 0.90
applyReportUIUpdatesFunction · 0.90
handleClickFunction · 0.85

Calls 1

applyUIEventFunction · 0.85

Tested by

no test coverage detected