mobx-state-tree-store-builder

MobX State Tree Store Builder

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "mobx-state-tree-store-builder" with this command: npx skills add planeinabottle/fitnessmobileapp/planeinabottle-fitnessmobileapp-mobx-state-tree-store-builder

MobX State Tree Store Builder

This skill helps create MobX State Tree stores following the established patterns in the Fitness Tracker App. It handles the complex setup required for proper TypeScript integration, RootStore injection, and consistent architectural patterns.

When to Use This Skill

Use this skill when you need to:

  • Create a new domain model (like ExerciseModel)

  • Build a collection store (like ExerciseStoreModel)

  • Add a new store to the RootStore

  • Extend existing stores with new functionality

  • Create proper TypeScript interfaces and snapshots

Store Types

Domain Models

Atomic data models that represent business entities. Examples: ExerciseModel , UserModel .

Pattern: types.model("Name", { ... }).views(...).actions(...)

Collection Stores

Stores that manage collections of domain models. Examples: ExerciseStore , StatsStore .

Pattern: types.model("StoreName", { collection: types.map(Model) }).views(...).actions(...)

Singleton Stores

Stores with single-instance data. Examples: UserStore , UiStore .

Pattern: types.model("StoreName", { ... }).views(...).actions(...)

Root Store Integration

All stores must be added to the RootStore for dependency injection:

export const RootStoreModel = types.model("RootStore", { // Add new store here newStore: types.optional(NewStoreModel, {}), // ... existing stores })

TypeScript Integration

Always export proper interfaces:

  • IStoreName

  • Instance type

  • IStoreNameSnapshotIn

  • Input snapshot type

  • IStoreNameSnapshotOut

  • Output snapshot type

Common Patterns

Computed Views

Use for derived data that depends on store state:

.views((self) => ({ get computedProperty() { return self.someData * 2 }, }))

Actions with Root Access

Use getRoot<IRootStore>(self) to access other stores:

.actions((self) => ({ someAction() { const rootStore = getRoot<IRootStore>(self) rootStore.otherStore.doSomething() }, }))

Async Actions

Use flow for async operations:

import { flow } from "mobx-state-tree"

.actions((self) => ({ asyncAction: flow(function* () { try { // async operations yield someAsyncCall() } catch (error) { // error handling } }), }))

File Organization

Store files go in app/models/ :

  • Domain models: ModelName.ts

  • Stores: StoreName.ts

  • Root store: RootStore.ts

Testing

Each store should have corresponding tests in app/models/tests/ .

References

See MST_PATTERNS.md for detailed patterns and examples from the codebase.

See STORE_TEMPLATES.md for reusable templates.

See ROOT_STORE_INTEGRATION.md for adding stores to RootStore.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Automation

react-native-storage-manager

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

react-native-i18n-workflow

No summary provided by upstream source.

Repository SourceNeeds Review
Automation

clinic-visit-prep

帮助患者整理就诊前问题、既往记录、检查清单与时间线,不提供诊断。;use for healthcare, intake, prep workflows;do not use for 给诊断结论, 替代医生意见.

Archived SourceRecently Updated
Automation

changelog-curator

从变更记录、提交摘要或发布说明中整理对外 changelog,并区分用户价值与内部改动。;use for changelog, release-notes, docs workflows;do not use for 捏造未发布功能, 替代正式合规审批.

Archived SourceRecently Updated