PillowPillow / ng2-webstorage

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

Having an empty string for prefix and separator causes infinite loop with @sessionStorage #67

Closed JordanFriendshuh closed 6 years ago

JordanFriendshuh commented 7 years ago

I have recently switched to this library from bdv-angular2-localstorage since you guys use the same annotation patterns. I didn't want our keys in session storage to change so I tried to set the prexfix and separator to "". When I do this and try to use the session storage annotation I get a maximum call stack error.

rjwijnen commented 6 years ago

I am using: Ng2Webstorage.forRoot({ prefix: '', separator: '', caseSensitive: true }) , and i don't get any errors in my applications.

PillowPillow commented 6 years ago

I m unable to reproduce this issue, please provide a sample repo.

WindSaber commented 6 years ago

I got the same issue

Ng2Webstorage.forRoot({ prefix: '', separator: '', caseSensitive: true })

image


But if I change the code inside the app.module like this, no error is presented

Ng2Webstorage.forRoot({ prefix: '', separator: '*', caseSensitive: true })


The code where I'm using the annotation looks like:

`import {Injectable} from '@angular/core'; import {HttpClient} from '@angular/common/http'; import {Observable} from 'rxjs/Observable'; import 'rxjs/add/observable/forkJoin'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; import {LocalStorage, LocalStorageService} from 'ngx-webstorage'; import {environment} from '../../environments/environment';

@Injectable() export class LangService { @LocalStorage() ls_wfcompras: any; }`

WindSaber commented 6 years ago

If somebody helps, I found another great repo where this and other problems are solved:

https://github.com/zoomsphere/ngx-store

PillowPillow commented 6 years ago

@WindSaber which version of angular and ngx-webstorage are you using?