Skip to content

feat: add storyinit event fired after restart and initial boot#116

Merged
rohal12 merged 1 commit intomainfrom
fix/115-storyinit-event
Mar 24, 2026
Merged

feat: add storyinit event fired after restart and initial boot#116
rohal12 merged 1 commit intomainfrom
fix/115-storyinit-event

Conversation

@rohal12
Copy link
Owner

@rohal12 rohal12 commented Mar 24, 2026

Summary

  • Adds Story.on('storyinit', callback) event that fires after executeStoryInit() completes — on initial boot and after every restart() call (including clearGameData/clearAllData)
  • Adds initCount counter to the store, incremented after StoryInit execution; the event subscription detects changes to this counter
  • Updates docs (story-api.md) and changelog

Closes #115

Test plan

  • New test: storyinit fires on restart via raw Zustand subscription
  • New test: storyinit fires via Story.on() API
  • New test: fires on every restart (3x restart → 3 callbacks)
  • Existing tests unaffected (978/978 pass)
  • npx tsc --noEmit clean

🤖 Generated with Claude Code

Games with external state engines need to re-push their state after a
restart. Add Story.on('storyinit') which fires after executeStoryInit()
completes on both initial boot and every restart() call (including
clearGameData/clearAllData which call restart internally).

Closes #115

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link

Release preview: merging this PR will publish v0.37.0 (minor bump from v0.36.2)

@github-actions
Copy link

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 77.6% 2619 / 3375
🔵 Statements 76.79% 2869 / 3736
🔵 Functions 67.79% 482 / 711
🔵 Branches 74.16% 1447 / 1951
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
src/index.tsx 0% 0% 0% 0% 21-207
src/store.ts 78.2% 71.57% 68.29% 80.3% 89, 123, 278-279, 342, 351-354, 385-390, 482, 517, 540-543, 557, 561-564, 576-648
src/story-api.ts 11.97% 6.45% 16.66% 12.68% 140-255, 268-346, 351-356, 371-418, 445-450, 462-497
Generated in workflow #186 for commit 8b509ae by the Vitest Coverage Report Action

@rohal12 rohal12 enabled auto-merge March 24, 2026 15:50
@rohal12 rohal12 merged commit 257ec90 into main Mar 24, 2026
5 checks passed
@rohal12 rohal12 deleted the fix/115-storyinit-event branch March 24, 2026 15:51
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.

No event fired after Story.restart() or Story.storage.clearGameData()

1 participant