fix: resolve nil pubsub preventing live game updates
All checks were successful
Deploy c4 / deploy (push) Successful in 45s

v.PubSub() was captured at startup before v.Start() initialized NATS,
so both stores held nil and notify() silently no-oped. Replace the
PubSub interface with a callback that evaluates v.PubSub() lazily at
call time.
This commit is contained in:
Ryan Hamamura
2026-02-20 12:37:28 -10:00
parent 91b5f2b80c
commit e68e4b48f5
3 changed files with 18 additions and 22 deletions

View File

@@ -81,8 +81,12 @@ func main() {
subFS, _ := fs.Sub(assets, "assets")
v.StaticFS("/assets/", subFS)
store.SetPubSub(v.PubSub())
snakeStore.SetPubSub(v.PubSub())
store.SetNotifyFunc(func(gameID string) {
v.PubSub().Publish("game."+gameID, nil)
})
snakeStore.SetNotifyFunc(func(gameID string) {
v.PubSub().Publish("snake."+gameID, nil)
})
// Home page - tabbed lobby
v.Page("/", func(c *via.Context) {