async-storage-plugin icon indicating copy to clipboard operation
async-storage-plugin copied to clipboard

Add Ability to Add Multiple Engines

Open simon-lammes opened this issue 4 years ago • 0 comments

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]
    },
  ]
})

simon-lammes avatar Mar 01 '21 16:03 simon-lammes