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
Currently there is no global state management for socketioxide so it is quite frustrating to manage state.
Most of the time it is needed to make a global OnceCell or something like that and then getting the state from the Cell each time it is required.
Because of the current architecture with the imbricated closures it is not possible to adopt the "Axum" way of managing state which is having only one typed field on handlers and then using a State extractor to extract it. It has many advantages because it allows to have State type checking at compilation and it is quite efficient.
The remaining way of achieving state management in socketioxide is to have either one dynamic OnceCell or a TypeMap stored in the Client and an extractor that extract the corresponding data. In case of failure it would not call the handler and a tracing error would be logged.
Things to do are :
Add a state module and a state struct with a dynamic TypeMap but only with creation fn (no mut ref). (behind a feature flag)
Add a field in the client module for the state struct (behind feature flag)
Pass a state reference to every handlers
Create a State extractor that would extract a given state from the TypeMap
The text was updated successfully, but these errors were encountered:
Currently there is no global state management for
socketioxide
so it is quite frustrating to manage state.Most of the time it is needed to make a global
OnceCell
or something like that and then getting the state from theCell
each time it is required.Because of the current architecture with the imbricated closures it is not possible to adopt the "Axum" way of managing state which is having only one typed field on handlers and then using a
State
extractor to extract it. It has many advantages because it allows to have State type checking at compilation and it is quite efficient.The remaining way of achieving state management in socketioxide is to have either one dynamic
OnceCell
or aTypeMap
stored in theClient
and an extractor that extract the corresponding data. In case of failure it would not call the handler and a tracing error would be logged.Things to do are :
TypeMap
but only with creation fn (no mut ref). (behind a feature flag)client
module for the state struct (behind feature flag)State
extractor that would extract a given state from the TypeMapThe text was updated successfully, but these errors were encountered: