Rank 1: Thread
Note
To answer this question, the vue/nuxt parts of the code can be ignored. I am not entirely sure if this would work as it currently is implemented. I am mainly trying to get get some validation, that subscriptions/unsubscriptions I made, make some sense. I am having some issues interpreting the documentations, mostly because of lack of examples for this particular case.
Context
I have recently integrated my Nuxt3 application flows with Appwrite SDKs in order to login, logout, verify and pretty much everything else. Middleware on the browser and on the server work as expected.
Problem
- My code constantly pokes Appwrite APIs to check if the user is authenticated before doing something. Works to some extent, but is probably not very performance friendly
- My code is not reactive, in other words, my interface does not change if a user changes state on the client side until, until I refresh the page.
I figured that to solve both of this problems, I should have a global store to hold account.get data. I figured the ideal way of doing this without "pushing" and "popping" state everywhere, is to use real time features to listen to state changes from the Appwrite Realtime SDK (inspired on the existing nuxt/supabase library approach - https://github.com/nuxt-modules/supabase/blob/8c035ac7c358934ef7c72fd4eb5b779da3c2f1ff/src/runtime/plugins/supabase.client.ts#L21).
Code snippet available below, in this thread.