router.initialized and router.updated lifecycle events
- Dominant language
- TypeScript
- Stars
- 8
- Forks
- 2
- Avg merge
- 13h 44m
- Merged PRs (30d)
- 1
Description
### Problem
There is no one-shot "router finished its first match pass" signal. After `setHistory` the router recalculates on every `locationUpdated`, but code that must run exactly once per scope — page-view analytics, hiding the splash screen, setting SSR HTTP status, distinguishing initial load from subsequent navigation — has to maintain a manual flag store. atomic-router covers this with `router.initialized`.
### Proposed solution
Two router-level events completing the lifecycle `setHistory → initialized (×1) → updated (×N)`:
```ts
router.initialized: Event<{ path: string; query: Query; activeRoutes: Route[] }>;
router.updated: Event<{ path: string; query: Query; activeRoutes: Route[] }>;
```
`initialized` fires once per scope after the first `openRoutesByPathFx.done` (flag kept in a store, not a closure — fork-safe). `updated` fires on every subsequent location change **only if** `path`+`query` actually changed (value dedupe, consistent with `route.updated`). Neither fires on the initial pass twice: first pass → `initialized` only, later passes → `updated` only.
### Alternatives considered
Manual `$initialized` flag store in userland; `openedOnServer` — per-route and fires per open, not "router ready once".
### Package
`@effector/router` (core)
Contributor guide
Research direction
Start in the @effector/router core at the setHistory and locationUpdated flow, then trace openRoutesByPathFx.done and compare the existing route.updated behavior. The work is done when the first pass emits initialized once, later path/query changes emit updated, and forked scopes do not share the initialization state.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 62/100