ionic-team / ionic-team/ionic-storage
curious why `Drivers` is `@hidden` and can it be made iterable?
- Lingua principale
- TypeScript
- Stelle
- 456
- Fork
- 97
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
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](https://github.com/ionic-team/ionic-storage/blob/b67aa24a89a7cf02aa391becebd620f87518c8af/lib/src/index.ts#L3))?
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](https://github.com/ionic-team/ionic-storage/blob/main/lib/src/index.ts#L45). It's also used in the [example code in the docs](https://github.com/ionic-team/ionic-storage#with-angular).
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)`
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia da lib/src/index.ts, in particolare dall’esportazione di Drivers e dai commenti su driverOrder, quindi confronta gli esempi Angular nella documentazione del repository. Determina lo stato pubblico previsto di Drivers e se l’ordinamento dei driver iterabili fa parte dell’API richiesta; il lavoro è completato quando il comportamento e l’utilizzo consigliato sono chiaramente definiti e documentati.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- angular, sqlite, typescript
- Ambito
- api, databases
- Tipo di issue
- Funzionalità
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 32/100