Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow override of storage #129

Open
firatoezcan opened this issue Jul 31, 2024 · 3 comments
Open

Allow override of storage #129

firatoezcan opened this issue Jul 31, 2024 · 3 comments

Comments

@firatoezcan
Copy link

Hey, I am implementing Supertokens right now for both native and web and I found that it is way harder than it should be because RN doesnt really has a good concept of loaders and in general it almost feels like useEffect is necessary to correctly get the correct states.

I did get a really good solution now that also uses useSyncExternalStore, however the snapshot function there cannot be async (and what I found online was buggy at best). This would be less of an issue if I could inject the storage function however as I already wrote a function that has sync updates and stores asynchronously in the background.

Is this something that would be feasible to implement?

@rishabhpoddar
Copy link
Contributor

Hey @firatoezcan could you please elaborate more on the issue with a code example perhaps? Thanks.

@firatoezcan
Copy link
Author

Instead of relying on calling the session functions which are async I'd like a synchronous way of getting the session information. So I set up a notifier for all events and every time an event occurs, I take a look at the storage. For web its easy as that is just parsing the cookies, but for RN it lies behind an async boundary. The gist of it looks as follows:
image

(Other code omitted for brevity)

@rishabhpoddar
Copy link
Contributor

I see. We do plan on allowing storage override (like we do for the web SDK), the timeline is unknown though. We welcome PRs.

Also for extra context, getting session information via our SDK functions will always be async cause our SDK also takes case of refreshing the session tokens if needed which requires a network call.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants