xxf-viewmodel

Provide a reusable ViewModel base with lifecycle management and state exposure for Swift iOS/macOS apps.

6|1|Updated May 22, 2025
One-click install
npx skills add https://github.com/NBXXF/xxf_ios --skill xxf-viewmodel
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: xxf-viewmodel
Source: https://github.com/NBXXF/xxf_ios/tree/main/skills/xxf-viewmodel
Command: npx skills add https://github.com/NBXXF/xxf_ios --skill xxf-viewmodel

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

XXFViewModel base class helps developers implement MVVM patterns by centralizing lifecycle, state management, and input/output streams, reducing boilerplate and preventing memory leaks.

Core Features & Use Cases

  • VM lifecycle management: automatic binding/unbinding across views.
  • State exposure via flows: outputs for the UI to react to.
  • Dependency injection readiness: works with xxf-di.

Quick Start

Create a new ViewModel subclass from the base and bind its outputs to the View using the XXFFlow pipeline.

Frequently Asked Questions about xxf-viewmodel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I reduce boilerplate when wiring ViewModels in Swift MVVM?

Reduce MVVM boilerplate by subclassing a reusable ViewModel base that centralizes lifecycle management, state exposure via flows, and input handling, eliminating repetitive binding code across iOS and macOS screens.

How do I manage ViewModel lifecycle and prevent memory leaks in iOS?

Manage ViewModel lifecycle safely by using a base class that handles automatic binding and unbinding across views, ensuring flows are cleaned up and preventing memory leaks during screen transitions.

Does this MVVM ViewModel base support dependency injection for iOS apps?

Yes, the MVVM ViewModel base supports dependency injection readiness and integrates with xxf-di, allowing you to inject services into your ViewModels while defining inputs, outputs, and lifecycle hooks.

How do I expose ViewModel state to the UI using flows in Swift?

Expose ViewModel state to the UI by utilizing the XXFFlow pipeline, where the base class provides output flows that the View reacts to, enabling reactive View-ViewModel binding without manual state synchronization.

Can I use this ViewModel lifecycle management on macOS as well as iOS?

Yes, the lifecycle-safe ViewModel base applies to both iOS and macOS apps that require View-ViewModel binding, input handling, and dependency injection across various screens and application flows.

What is the best way to handle View-ViewModel binding and input streams in Swift?

Handle View-ViewModel binding by leveraging a reusable base class that defines structured input and output streams via flows, centralizing state management and lifecycle hooks for consistent MVVM architecture.