fix: resolve nil pubsub preventing live game updates
All checks were successful
Deploy c4 / deploy (push) Successful in 45s
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:
8
main.go
8
main.go
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user