Spark component view model

From leboncoin/spark-ios · View interactive version

Spark component view model is an AI agent skill from the GitHub repository leboncoin/spark-ios. Create or update an view model file in the ViewModel folder in Sources of a spark-ios-component-XXX and add or update unit tests.

How to use this skill

Skill file

Add Repository Skill

Overview & Prerequisites

This skill guides you to implement/update an view model in spark component.

Component Selection

Parameter Handling:

Once the component is selected, all operations must be performed in Modules/Components/{component-name}/ folder.

Use the files in the template folder as reference to manage the view model and the unit tests.

Rules

The ViewModel file must respect theses rules :

1. some @Published private(set) var that only set by use cases and consume by the views

2. some var. Setted by the views and the setup function. Manage the didSet to call use case if it is needed

3. A private var alreadyUpdateAll use to know if the viewModel is setup are not.

4. A list of usecase used by the viewmodel to set the @Published properties.

5. The init with all use cases (and with the default implementation)

6. The setup func with all needed properties send by the init. Set the alreadyUpdateAll to true.

7. The private setter func. Use to set @Published from use cases.

Workflow

Code Conventions

Test Implementation

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.