Skip to content

docs: document recommended state/controller registration pattern for consumer apps#18

Merged
anilcancakir merged 2 commits intomainfrom
docs/state-controller-registration-pattern
Apr 4, 2026
Merged

docs: document recommended state/controller registration pattern for consumer apps#18
anilcancakir merged 2 commits intomainfrom
docs/state-controller-registration-pattern

Conversation

@anilcancakir
Copy link
Copy Markdown
Contributor

Summary

  • Add doc/architecture/controllers.md — architecture reference covering lazy singleton pattern (Magic.findOrPut), MagicController + MagicStateMixin usage, controller lifecycle, view binding, and consumer app registration decision tree
  • Add doc/guides/state-management.md — practical getting-started guide with end-to-end examples (state class + view + test) for consumer app developers
  • Update assets/stubs/install/app_service_provider.stub with state registration guidance comments
  • Add cross-references in doc/architecture/service-provider.md (TIP callout + Related link)
  • Update CHANGELOG.md and README.md documentation table

Closes #17

Test plan

  • Verify doc/architecture/controllers.md renders correctly and TOC anchors link to sections
  • Verify doc/guides/state-management.md code examples are complete and match actual API
  • Verify app_service_provider.stub comment indentation matches surrounding code (8 spaces)
  • Verify cross-reference links in service-provider.md resolve correctly
  • Run flutter analyze --no-fatal-infos — no new warnings from stub change

…consumer apps

Add architecture reference (doc/architecture/controllers.md) covering the
lazy singleton pattern, MagicController + MagicStateMixin usage, controller
lifecycle, view binding, and a decision tree for eager vs lazy vs per-view
registration. Add practical getting-started guide (doc/guides/state-management.md)
with end-to-end examples. Update scaffolded app_service_provider.stub with
state registration guidance comments. Add cross-references in service-provider.md.

Closes #17
Copilot AI review requested due to automatic review settings April 4, 2026 19:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds new documentation to standardize how consumer apps should register and use Magic Framework controllers/state in apps built on top of Magic Starter, plus small cross-references and stub guidance to reduce inconsistent patterns across projects.

Changes:

  • Added architecture + guide docs covering the recommended lazy singleton controller pattern (Magic.findOrPut), view binding patterns, and testing.
  • Updated installation stub (app_service_provider.stub) with guidance on when to register state eagerly in boot().
  • Added cross-links in existing docs and surfaced the new docs in README + CHANGELOG.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 12 comments.

Show a summary per file
File Description
README.md Adds new documentation links for controller/state registration and state management guidance
doc/guides/state-management.md New end-to-end guide with patterns + example controller/view/test snippets
doc/architecture/service-provider.md Adds a TIP + related link to the new controller/state registration doc
doc/architecture/controllers.md New architecture reference describing controller patterns, lifecycle, view binding, and testing
CHANGELOG.md Notes the newly added documentation and stub guidance under Unreleased
assets/stubs/install/app_service_provider.stub Adds scaffold comments explaining recommended state registration strategy

- controllers.md: clarify MagicStateMixin<bool> is most common, not
  universal (Newsletter/OTP use untyped); qualify NavigatesRoutes usage;
  note NotificationsListView as MagicStatefulView exception; fix
  views-and-layouts Related URL (architecture → basics)
- state-management.md: fix "five-state" → "four-state"; fix
  _isSubmitting → _isLoading consistency; fix flutter/widgets.dart →
  flutter/material.dart for Icons.* usage; rename Pattern B section
  to "Manual Access" matching actual content
- README.md: use hosted doc URLs instead of repo-relative paths
- stub: replace local doc path with generic package docs reference
@anilcancakir anilcancakir merged commit d6029b3 into main Apr 4, 2026
1 check passed
@anilcancakir anilcancakir mentioned this pull request Apr 4, 2026
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

docs: document recommended state/controller registration pattern for consumer apps

2 participants