You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
We have a project plan that to use the Datastore with the WebWorker, and store the synced data into the local IndexedDB.
But the current behavior is it will pick the AsyncStorageAdapter instead of IndexedDBAdapter. As it only allow to use IndexedDBAdapter when browserOrNode().isBrowser is true.
Describe the solution you'd like
Currently, required('@aws-amplify/core').browserOrNode().isBrowser is return as false when we use the WebWorker, as this flag is check by typeof window !== 'undefined' && typeof window.document !== 'undefined', which the window will always be, by default, undefined in WebWorker.
So I suggest providing isWebWorker flag in the JS, with the following logic: typeof self !== 'undefined' && self.constructor.name === 'DedicatedWorkerGlobalScope';
And update the getDefaultAdapter, to check (isBrowser && window.indexedDB) && (isWebWorker && self.indexedDB).
Describe alternatives you've considered
-
Additional context
-
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
We have a project plan that to use the Datastore with the WebWorker, and store the synced data into the local IndexedDB.
But the current behavior is it will pick the AsyncStorageAdapter instead of IndexedDBAdapter. As it only allow to use IndexedDBAdapter when
browserOrNode().isBrowser
is true.Describe the solution you'd like
Currently,
required('@aws-amplify/core').browserOrNode().isBrowser
is return as false when we use the WebWorker, as this flag is check bytypeof window !== 'undefined' && typeof window.document !== 'undefined'
, which the window will always be, by default, undefined in WebWorker.So I suggest providing
isWebWorker
flag in the JS, with the following logic:typeof self !== 'undefined' && self.constructor.name === 'DedicatedWorkerGlobalScope';
And update the getDefaultAdapter, to check
(isBrowser && window.indexedDB) && (isWebWorker && self.indexedDB)
.Describe alternatives you've considered
-
Additional context
-
The text was updated successfully, but these errors were encountered: