-
Notifications
You must be signed in to change notification settings - Fork 19
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
Switch to IndexedDB #26
Comments
Issue-Label Bot is automatically applying the label Links: app homepage, dashboard and code for this bot. |
@aidarkhanov Thank you for submitting this pull request. However, you made some good points. Since I do intend on using service workers in the near future with this SDK it would make sense to move to IndexedDB, the only issue I see there is that the API is very difficult to work with, and using a library like IDB will double the size of this lib. It is currently very easy to extend this library to work with other storage solutions. The constructor of Auth receives a interface Storage {
/** Save to local storage */
set(key: string, value: string): Promise<void>;
/** Get from local storage */
get(key: string): Promise<string | null>;
/** Remove from local storage */
remove(key: string): Promise<void>;
} And the current implementation is close to: const storageApi: Storage = {
async set(k: string, v: string) {
return localStorage.setItem(k, v);
},
async get(k: string) {
return localStorage.getItem(k);
},
async remove(k: string) {
return localStorage.removeItem(k);
}
}; So you can use this as a reference for IndexedDB. To recap; I will switch to IndexedDB in the future(probably before v1.0.0) but I can't yet tell you exactly when since I'm currently focused on refactoring Please let me know if you have any suggestions. I will leave this issue open for discussion and untill it is implemented(or otherwise). |
FWIW, there are some contexts where local storage will remain the better option: for example, Safari forbids IDB access in iframes. I like your dependency injection approach! |
@andymatuschak thank, I didn’t know that. I will take that into consideration. |
Hello, thank you for this project! I want to leave an issue to let you know that I am working on switching from local storage to IndexedDB. Here are the reasons for doing so:
The benefits above are also communicated by the Firebase team.
Also, what do you think of making IndexedDB default and only storage?
The text was updated successfully, but these errors were encountered: