Skip to content

docs: align screen lifecycle docs with single-GenServer navigation - #76

Draft
minibikini wants to merge 1 commit into
GenericJam:masterfrom
minibikini:fix/doc-lifecycle-single-genserver
Draft

docs: align screen lifecycle docs with single-GenServer navigation#76
minibikini wants to merge 1 commit into
GenericJam:masterfrom
minibikini:fix/doc-lifecycle-single-genserver

Conversation

@minibikini

Copy link
Copy Markdown

The docs describe a per-screen-process model that the shipped implementation doesn't have, and terminate/2 semantics that never fire the way they're described.

What the code actually does (verified against lib/mob/screen.ex):

  • One Mob.Screen GenServer owns the whole navigation stack. The active screen is a {module, socket} pair in its state.
  • push mounts the next module in that same process and stores {module, socket} in nav_history.
  • pop / pop_to / pop_to_root / reset restore a snapshot from nav_history — they start no process and call no lifecycle callback.
  • terminate/2 runs only when the whole Mob.Screen GenServer stops (app exit, crash, shutdown), and delegates to the module active at that time only.

The native side confirms this is intentional: mob_handle_back (iOS mob_nif.m, Android mob_nif.zig) looks up a single registered :mob_screen process, and renderer.ex calls set_root/1 once per render. There is no per-screen process anywhere.

Docs fixed in this PR

  • guides/screen_lifecycle.md — "Each screen in the navigation stack is a separate, supervised process" and the "popped → terminate/2" diagram step.
  • guides/navigation.md — "Passing data on pop" claimed popping restores a still-running per-screen process.
  • lib/mob/screen.ex @moduledoc — claimed one supervised GenServer per screen with per-screen crash isolation.
  • PLAN.md — "terminate/2 is called on every screen process exit" used for crash reporting.

No runtime code changes. Formatting + mix credo --strict are clean.

This is documentation-only. If a per-screen actor model is actually the intended direction, this PR highlights exactly where the shipped implementation and the docs diverge, and it would be worth deciding which way to take it before md docs keep promising isolate process-per-screen behaviour that doesn't exist.

guides/screen_lifecycle.md, navigation.md, Mob.Screen moduledoc, and PLAN.md
claimed each screen in the nav stack is a separate supervised process and
that popping calls terminate/2. In reality one Mob.Screen GenServer owns the
whole stack: push mounts in the same process, pop restores a snapshot from
nav_history. terminate/2 fires only when the whole GenServer stops. Rewrite
the affected sections to match the shipped model.
@minibikini
minibikini marked this pull request as draft August 8, 2026 19:21
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.

1 participant