You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is easy to access the global store inside the GET, POST, PUT, DELETE route handlers. As from the v1.0 docs:
import{Elysia}from'elysia'newElysia().state('version',1).get('/a',({store: { version }})=>version)// easily having access to the store object.get('/b',({ store })=>store)// also works fine.listen(3000)
But how could I access the store in a websocket route?
import{Elysia}from'elysia'newElysia().ws('/ws',// --------How can I get the store value here?--------{message(ws,message){ws.send(message)}}).listen(3000)
Also, I want to be able to access and update the store properties inside the open() callback, after doing some operations, like this:
import{Elysia}from'elysia'newElysia().ws('/ws',{open(ws){// do some operationsstore.myProperty=true// want to update store value here, but how?}}}).listen(3000)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
It is easy to access the global
store
inside the GET, POST, PUT, DELETE route handlers. As from the v1.0 docs:But how could I access the
store
in a websocket route?Also, I want to be able to access and update the store properties inside the
open()
callback, after doing some operations, like this:Beta Was this translation helpful? Give feedback.
All reactions