Mobile MVI
БесплатноБез исполняемых скриптовНе проверенDesigns, implements and tests screens with MVI on Android, iOS and Flutter: intents as sealed types, one immutable state, a pure reducer and side effects fed…
от ahmadhussain0335132 установки в других каталогахОб этом скилле
MVI for mobile apps
Build screens where every change goes through one loop: the UI sends an intent, a pure reducer computes the next state, effects do the IO outside the reducer and report back as new actions. State transitions become plain functions that are trivial to test, replay and reason about under concurrency.
When to use
- A screen has many events that interact: typing, retry, refresh, pagination, selection, live updates.
- Requests race each other (debounced search, rapid toggles, BLE or socket updates arriving mid-request).
- State transitions must be auditable or tested exhaustively (payments, onboarding wizards, editors).
- The codebase already uses Bloc, TCA, Orbit, Mavericks or a hand-rolled store, and new code must fit.
- Reviewing an MVI store for impure reducers, lost effects or oversized state.
Not for: simple read-only or CRUD screens; MVVM with a single UiState is enough there
(use mobile-mvvm). Do not convert a whole app to MVI to fix one complex screen.
The loop
+----------------------- State -----------------------+
v |
UI renders State --- Intent ---> Store --- (State, Action) ---> Reducer (pure)
| ^
| effect for this action | Result action
v |
Effect runner (IO, timers, navigation)
| Part | What it is | Kotlin | Swift | Dart |
|---|---|---|---|---|
| Intent | What the user did | sealed interface SearchIntent |
enum SearchAction cases |
sealed class SearchEvent |
| Result | What an effect produced | sealed interface SearchResult |
more SearchAction cases |
internal result classes |
| State | Everything the screen renders | data class |
struct: Equatable |
@immutable class or Equatable |
| Reducer | (State, Action) -> State, no IO |
top-level or object function |
static func |
top-level function |
| Effect | IO, timers, navigation, analytics | coroutine in viewModelScope |
Task owned by the store |
code in a Bloc handler |
| Store | Holds state, runs the loop | ViewModel + StateFlow |
@MainActor @Observable class |
Bloc |
Workflow
- Confirm the screen needs MVI (see When to use). If not, use
mobile-mvvm. - Load the reference for the platform: Kotlin and Compose, Swift and SwiftUI, Dart with Bloc.
- Write the
State: the minimum the UI renders. Derive the rest with computed properties. - List intents from the UI as a sealed type, named after what happened (
QueryChanged,RetryClicked). - List results the effects can produce (
Loaded,Failed), each carrying what the reducer needs to reject stale data (for example the query it was for). - Write the reducer and its tests first. It is pure, so the tests need no mocks or dispatchers.
- Write the store: apply the reducer, then start the effect for the action with an explicit concurrency policy (cancel previous, drop new, or queue).
- Decide how one-off effects reach the UI: state field first, effect channel only if needed.
- Build the UI: render
State, send intents, never mutate state directly. - Write effect tests with fakes and virtual time. Run the existing test suite and report failures.
Rules
1. Intents are one sealed type named after what happened
Kotlin:
// BAD: commands named after implementation, open to anything
fun setLoading(value: Boolean)
fun callSearchApi(query: String)
// GOOD
sealed interface SearchIntent {
data class QueryChanged(val query: String) : SearchIntent
data object RetryClicked : SearchIntent
data class ResultClicked(val id: String) : SearchIntent
}
Swift:
enum SearchAction: Equatable, Sendable {
case queryChanged(String) // from the view
case retryTapped
case resultTapped(Repo.ID)
case detailsDismissed
case loaded(query: String, [Repo]) // from effects
case failed(query: String)
}
Dart:
sealed class SearchEvent { const SearchEvent(); }
final class QueryChanged extends SearchEvent { const QueryChanged(this.query); final String query; }
final class RetryPressed extends SearchEvent { const RetryPressed(); }
- Exhaustive
when/switchover a sealed type makes the compiler flag every unhandled intent. - Kotlin can split public intents and internal results into two sealed sub-interfaces of one
SearchAction, so the UI cannot send a result. Swift enums cannot; mark effect-only cases with a comment.
2. One immutable State; derive instead of duplicating
// BAD: flags that can contradict each other, list duplicated for filtering
data class SearchState(
val isLoading: Boolean, val isError: Boolean, val isEmpty: Boolean,
val items: L
Установить Mobile MVI в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Mobile MVI?
Designs, implements and tests screens with MVI on Android, iOS and Flutter: intents as sealed types, one immutable state, a pure reducer and side effects fed back as actions, using Kotlin StateFlow stores, Swift @Observable stores (TCA as an option) and Dart Bloc or Cubit. Use for screens with many interacting events, debounced search or racing requests, or when adopting or reviewing Bloc or Redux-style code.
Как установить скилл Mobile MVI?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Mobile MVI запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic