DEV Community

loading...

Discussion on: Nuxt-Socket.IO: How Namespaces Config May Make Your Life Insanely Easier

Collapse
ahereandnow profile image
A-Here-And-Now

It's okay. This seems like a great tool. And frankly, it turned out that it would be better to source handling of namespaces and rooms on the server side, so your current implementation is arranged perfectly for me. Thank you for writing this! It does make it simpler to manage reactivity by a lot, in my opinion.

Thread Thread
richardeschloss profile image
Richard Schloss Author

I fully agree. I was thinking that maybe the server would already have an API it supports, perhaps like:

const api = Object.freeze({
  version: 1.14,
  addUser() { ... },
  sendMsg() { ... }
})

And then maybe a specific set of events can be reserved for the dynamic api use, so that the client listen for "serverApi" event, and the server may handle it like:

io.on('connection', (socket) => {
  socket.emit('serverApi', { api: Object.keys(api), version: api.version })
})

And then maybe when the client receives that api, dynamically configure the namespace emitters. And that might be pretty cool, because that could be a lot less manual config for the developer to do.