ngxs-labs / async-storage-plugin

⏱ WIP: Async Storage Plugin
MIT License
34 stars 14 forks source link

Add Ability to Add Multiple Engines #161

Open simon-lammes opened 3 years ago

simon-lammes commented 3 years ago

As a user of the library, I would like to be able to provide different storage engines for specific stores, so that I can store secret states like access tokens in secret storage (in Ionic for example) while storing other state in usual storage.

Currently, it is only possible to specify one storage engine within the initialization of the module:

NgxsAsyncStoragePluginModule.forRoot(IonicStorageEngine, {
  key: [SettingsState, AuthenticationState]
})

However, say I want the AuthenticationState stored in a secured storage. I need another Storage engine for that. I would suggest to make the following configuration (or something similar) possible:

NgxsAsyncStoragePluginModule.forRoot({
  storageStrategies: [
    {
      engine: IonicStorageEngine,
      key: [SettingsState]
    },
    {
      engine: IonicSecureStorageEngine,
      key: [AuthenticationState]
    },
  ]
})