matlab/matlab-agentic-toolkit / skills-catalog/matlab-app-building/matlab-build-app
matlab-build-app
UnverifiedBuild MATLAB apps from requirements to working code. Asks discovery questions (or skips them when the path is known), recommends UIFigure or UIHTML architecture, identifies layout archetype (Dashboard, Explorer, Tabbed, Wizard, Canvas), produces an implementation plan, and executes the build. For UIFigure apps, optionally serializes as App Designer (.mlapp or plain-text .m + .xml). Use when a user wants to build a MATLAB app, create a GUI, make an interactive tool, build a uifigure app, build a uihtml app, build an App Designer app, build a .mlapp app, build a plain-text App Designer app, or asks which approach to use. Also use when user describes spatial layout needs: dashboard, control panel, sidebar, tabs, wizard, stepper, canvas, workspace.
references/uihtml/mvvm-view-binding.md
View on GitHub# View Binding Pattern
Complete MainView class demonstrating how to bind a JavaScript View to a ViewModel using Observable subscriptions.
## MainView Class
```javascript
// views/main-view.js
export class MainView {
constructor(viewModel, containerElement) {
this.viewModel = viewModel;
this.container = containerElement;
this.unsubscribers = [];
this._createUI();
this._bindToViewModel();
}
destroy() {
// Clean up all subscriptions to prevent memory leaks
this.unsubscribers.forEach(unsub => unsub());
this.unsubscribers = [];
this.container.replaceChildren();
}
_createUI() {
// Create DOM structure
const app = document.createElement('div');
app.className = 'app';
const inputRow = document.createElement('div');
inputRow.className = 'form-row';
this.inputField = document.createElement('input');
this.inputField.type = 'number';
this.inputField.placeholder = 'Enter value';
inputRow.appendChild(this.inputField);
this.resultLabel = document.createElement('span');
this.resultLabel.className = 'result';
this.processBtn = document.createElement('button');
this.processBtn.className = 'btn btn-primary';
this.processBtn.textContent = 'Process';
this.resetBtn = document.createElement('button');
this.resetBtn.className = 'btn btn-secondary';
this.resetBtn.textContent = 'Reset';
const buttonRow = document.createElement('div');
buttonRow.className = 'button-row';
buttonRow.appendChild(this.processBtn);
buttonRow.appendChild(this.resetBtn);
this.statusLabel = document.createElement('div');
this.statusLabel.className = 'status';
this.errorLabel = document.createElement('div');
this.errorLabel.className = 'status-message error';
app.appendChild(inputRow);
app.appendChild(this.resultLabel);
app.appendChild(buttonRow);
app.appendChild(this.statusLabel);
app.appendChild(this.errorLabel);
this.container.appendChild(app);
// Wire UI events to ViewModel commands
this.processBtn.addEventListener('click', () => {
const value = parseFloat(this.inputField.value) || 0;
this.viewModel.processCommand(value);
});
this.resetBtn.addEventListener('click', () => {
this.viewModel.resetCommand();
this.inputField.value = '';
});
}
_bindToViewModel() {
const vm = this.viewModel;
// Subscribe to each Observable — View updates automatically
this.unsubscribers.push(
vm.displayValue.subscribe(value => {
this.resultLabel.textContent = value;
})
);
this.unsubscribers.push(
vm.isProcessing.subscribe(busy => {
this.processBtn.disabled = busy;
this.resetBtn.disabled = busy;
this.inputField.disabled = busy;
})
);
this.unsubscribers.push(
vm.statusMessage.subscribe(msg => {
this.statusLabel.textContent = msg;
})
);
this.unsubscribers.push(
vm.errorMessage.subscribe(msg => {
this.errorLabel.textContent = msg;
this.errorLabel.style.display = msg ? 'block' : 'none';
})
);
this.unsubscribers.push(
vm.canSubmit.subscribe(canSubmit => {
this.processBtn.disabled = !canSubmit;
})
);
}
}
```
## View Design Guidelines
- All DOM creation and manipulation happens in the View only
- Use `subscribe()` to bind ViewModel observables to DOM updates
- Store unsubscribe functions and call them in `destroy()` to prevent leaks
- Wire user events (click, input) to ViewModel commands
- The View never talks to the Model directly
## Binding Patterns
### Simple binding (one observable → one DOM update)
```javascript
this.unsubscribers.push(
vm.statusMessage.subscribe(msg => {
this.statusLabel.textContent = msg;
})
);
```
### Conditional display
```javascript
this.unsubscribers.push(
vm.errorMessage.subscribe(msg => {
this.errorLabel.textContent = msg;
this.errorLabel.style.display = msg ? 'block' : 'none';
})
);
```
### Multi-property binding (subscribe to each independently)
```javascript
// Both isProcessing and canSubmit affect the button
this.unsubscribers.push(
vm.isProcessing.subscribe(busy => {
this.processBtn.disabled = busy;
})
);
this.unsubscribers.push(
vm.canSubmit.subscribe(can => {
this.processBtn.disabled = !can;
})
);
```
### List rendering
```javascript
vm.items.subscribe(items => {
const fragment = document.createDocumentFragment();
for (const item of items) {
const li = document.createElement('li');
li.textContent = item.name;
fragment.appendChild(li);
}
this.list.replaceChildren(fragment);
});
```
## Cleanup
Always call `destroy()` when switching views or removing the app:
```javascript
// Example: switching between views
function showDetailView() {
currentView.destroy();
currentView = new DetailView(viewModel, container);
}
```
----
Copyright 2026 The MathWorks, Inc.
----
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |