-
Notifications
You must be signed in to change notification settings - Fork 136
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
feat: storage options, change priority or use custom #908
Conversation
🦋 Changeset detectedLatest commit: 8332060 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Awesome! there's a new open issue I think this would partly solve (complete web worker support is TBD, but gets us closer) #907 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks awesome! Just some questions/nits but nothing blocking
packages/browser/src/core/storage/__tests__/prioritizedListStorage.test.ts
Outdated
Show resolved
Hide resolved
packages/browser/src/core/storage/__tests__/prioritizedListStorage.test.ts
Outdated
Show resolved
Hide resolved
packages/browser/src/core/storage/__tests__/prioritizedListStorage.test.ts
Outdated
Show resolved
Hide resolved
packages/browser/src/core/storage/__tests__/prioritizedListStorage.test.ts
Outdated
Show resolved
Hide resolved
Great to see this being worked on. Note that getItem(): Promise<any> | any;
setItem(): Promise<any> | any;
removeItem(): Promise<any> | any; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! There's a lot to like about this PR, such as the refactoring. Blocking for some more discussion/review of this API, since there is no SDD.
Can we base Storage on the idiomatic Web Storage API (and/or with AsyncStorage support per @kyranjamie comment), rather than using the same interface as UniversalStorage? The UniversalStorage interface is both larger than I think it needs to be and confusing and I would hesitate to commit to this as our main public API for storage behavior.
Other concerns I have as a user are similarly around UniversalStorage and the ways it differs from what I'd expect from a typical storage interface.
- storage.getAndSync vs storage.get -- the former is an implementation detail. I'd be confused how to implement these and why if I'm just adding some basic storage implementatio, and what I'm expecting to be syncing with if there's only one store. Consumers can power up their storage implementation whichever way they want. if they want to combine cookies and indexDB into one class, they can go ahead. Maybe we don't need to complicate our interface.
- Why do I need to implement 'type' if storage only accepts a single store instance?
- can we make .available not required?
Agree on this.
I think this was due to an old approach I took (?) doesn't seem like I need this anymore. Fine with removing it.
I actually think we should keep this one. That way you can do fallbacks of Storage systems abstracting a little bit more of how you know if they are ready. I'm ok with switching from the |
Adds a
storage
option to analytics client.This can be used to specify a particular order for storage systems. e.g.
or
This is useful for web apps that might use multiple domains/subdomains to use cookies over local storage.
User
package toStorage
asUser
had become too bloated.UniversalStorage
option for overriding particularStoreType
is removed as the behaviour was getting complex to maintain if the order is also switchable. It is recommended to create aUniversalStorage
object with the particular systems instead.UniversalStorage
arguments to prevent passing aroundcookieOptions
as an specific thing all over the place. New API should be more extensible if other storages require any additional settings.Store
class to reuse the same interface ofUniversalStorage
as they were pretty much the same.WIP: Custom Storage support
[✔︎] I've included a changeset (psst. run
yarn changeset
. Read about changesets here).