PillowPillow / ng2-webstorage

Localstorage and sessionstorage manager - Angular service
MIT License
428 stars 91 forks source link

Session decorators don't use the modules config for key names #155

Open Way opened 3 years ago

Way commented 3 years ago

Versions (please complete the following information):

Describe the bug Decorators do not always take into account the module configuration in the forRoot.

I configured the NgxWebstorageModule like this:

NgxWebstorageModule.forRoot({
  prefix: 'app',
  separator: '.'
})

All values that I set via the services are correctly set as app.[key]. But with the decorators it happens that a value is saved as ngx-webstorage|[key]. So it seems that decorators use the default configuration of the module. I suspect a race condition but how can I avoid it? The NgxWebstorageModule.forRoot() is loaded directly into the CoreModule of my app as the first module.

To Reproduce Unfortunately, I cannot simply reproduce the problem myself in a simple example, since it does not occur here.

Has anyone ever noticed the problem?

Expected behavior I expect that all values are set either by service or by decorator should use the given configuration to create their keys.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context The application in which it occurs has a bunch of lazy-loaded modules, uses a CoreModule for all forRoot modules that only need to be instantiated once in the AppModule and a SharedModule that is shared with the lazy modules. Even when I put the NgxWebstorageModule.forRoot() in the app.module at the very beginning of the imports, the issue stays the same.