pass the api client instance to the services when initializing them inside the stores. do not import globally like this
Problems
I ended up having a store which was mostly overlapped with the settings store.
So maybe that store should be updated to be the central one and it should also deal with apiClient callbacks (which are now set in messages store).
I was managing the apiClient as a composable, but then I had to get that composable in every store, and pass that manually to each service
All the services had to be reworked to accept the apiClient as input
It was more code, less clear, harder to understand.
Solution
There is now a ApiService, imported directly from other services. So MemoryService just imports the apiClient (as it is now)
the ApiService contains apiClient, which is initialized in App.vue with the jwt.
Notes
fixed double apiClient instancing, that was causing this:
now it only connects once
fixed the reconnection bug:
more retries (please note they are cumulative, retries is not reset on reconnection and I don't know how to do it)
home view textarea is reactivated on ws connection (it remained deactivated because the error flag was not reset)
I tried to follow these instructions:
Problems
settings
store. So maybe that store should be updated to be the central one and it should also deal withapiClient
callbacks (which are now set inmessages
store).apiClient
as a composable, but then I had to get that composable in every store, and pass that manually to each serviceapiClient
as inputSolution
ApiService
, imported directly from other services. SoMemoryService
just imports the apiClient (as it is now)ApiService
containsapiClient
, which is initialized inApp.vue
with the jwt.Notes
apiClient
instancing, that was causing this:retries
(please note they are cumulative,retries
is not reset on reconnection and I don't know how to do it)