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
OK so I'm just returning to some Angular stuff after about a year off and seems like I've arrived just as there are breaking changes required on the storage.
I'm working through the documentation and trying to distill the best practices out of it.
I'm adding in the sqlite support.
Driver Order
Firstly I got stuck a bit reading through the source code to make sure what the correct order of the drivers should be.
I'm aiming to use the sqllite driver, but it seems like it then puts the responsibility of taking control of all the other drivers as well. I didn't know which was the best order to put them in.
Reading through the code I've settled on this:
import { IonicStorageModule } from '@ionic/storage-angular';
import { Drivers } from '@ionic/storage';
import * as CordovaSQLiteDriver from 'localforage-cordovasqlitedriver';
@NgModule({
// snip
imports: [
// snip
IonicStorageModule.forRoot({
driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB, Drivers.LocalStorage]
}) ],
Drivers Hidden
Which brings me to the second thing - why is the Drivers exported but @hidden (see here)?
Finally, would it be possible / practical to make Drivers iterable? Instead of taking responsibility for getting the order right this time, and having to maintain that in the future, I thought I was being clever to try this:
OK so I'm just returning to some Angular stuff after about a year off and seems like I've arrived just as there are breaking changes required on the storage.
I'm working through the documentation and trying to distill the best practices out of it.
I'm adding in the sqlite support.
Driver Order
Firstly I got stuck a bit reading through the source code to make sure what the correct order of the drivers should be.
I'm aiming to use the sqllite driver, but it seems like it then puts the responsibility of taking control of all the other drivers as well. I didn't know which was the best order to put them in.
Reading through the code I've settled on this:
Drivers Hidden
Which brings me to the second thing - why is the
Drivers
exported but@hidden
(see here)?This makes it feel like I shouldn't be using it, but I would prefer not to use strings in my list like the comments seem to hint at. It's also used in the example code in the docs.
Also the second code example only adds in one of them, which was confusing:
driverOrder: [CordovaSQLiteDriver._driver, Drivers.IndexedDB]
Drivers Iterable?
Finally, would it be possible / practical to make
Drivers
iterable? Instead of taking responsibility for getting the order right this time, and having to maintain that in the future, I thought I was being clever to try this:driverOrder: [CordovaSQLiteDriver._driver, ...Drivers]
But the compiler politely declined that idea with:
Type '{ SecureStorage: string; IndexedDB: string; LocalStorage: string; }' must have a '[Symbol.iterator]()' method that returns an iterator.ts(2488)
The text was updated successfully, but these errors were encountered: