diff --git a/src/ngx-store.ts b/src/ngx-store.ts index 9c9da2b..5535804 100644 --- a/src/ngx-store.ts +++ b/src/ngx-store.ts @@ -1,6 +1,6 @@ // Public classes. import { NgModule } from '@angular/core'; -import { WebStorageService, CookiesStorageService, LocalStorageService, SessionStorageService, SharedStorageService } from './service/index'; +import { CookiesStorageService, LocalStorageService, SessionStorageService, SharedStorageService } from './service/index'; export { CookieStorage, LocalStorage, SessionStorage, SharedStorage, SharedStorage as TempStorage } from './decorator/webstorage'; export { WebStorageService, CookiesStorageService, LocalStorageService, SessionStorageService, SharedStorageService, SharedStorageService as TempStorageService } from './service/index'; diff --git a/src/service/local-storage.service.ts b/src/service/local-storage.service.ts index 086048f..3bd55c0 100644 --- a/src/service/local-storage.service.ts +++ b/src/service/local-storage.service.ts @@ -1,7 +1,7 @@ import { WebStorageService } from './webstorage.service'; import { localStorageUtility } from '../utility/index'; import { Injectable } from '@angular/core'; -import { Observable, fromEvent, merge } from 'rxjs'; +import { fromEvent, merge } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { NgxStorageEvent } from '../utility/storage/storage-event'; diff --git a/src/service/session-storage.service.ts b/src/service/session-storage.service.ts index 103074c..300d810 100644 --- a/src/service/session-storage.service.ts +++ b/src/service/session-storage.service.ts @@ -1,7 +1,7 @@ import { WebStorageService } from './webstorage.service'; import { sessionStorageUtility } from '../utility/index'; import { Injectable } from '@angular/core'; -import { Observable, fromEvent, merge } from 'rxjs'; +import { fromEvent, merge } from 'rxjs'; import { filter, map } from 'rxjs/operators'; import { NgxStorageEvent } from '../utility/storage/storage-event'; diff --git a/src/service/shared-storage.service.ts b/src/service/shared-storage.service.ts index 03c9c77..5380727 100644 --- a/src/service/shared-storage.service.ts +++ b/src/service/shared-storage.service.ts @@ -1,7 +1,6 @@ import { WebStorageService } from './webstorage.service'; import { sharedStorageUtility } from '../utility/index'; import { Injectable } from '@angular/core'; -import { sharedStorage } from '../utility/storage/shared-storage'; @Injectable() export class SharedStorageService extends WebStorageService { diff --git a/src/service/webstorage.service.ts b/src/service/webstorage.service.ts index 4e04daf..5e4d5f0 100644 --- a/src/service/webstorage.service.ts +++ b/src/service/webstorage.service.ts @@ -3,7 +3,7 @@ import { WebStorageUtility } from '../utility/webstorage.utility'; import { WebStorageServiceInterface } from './webstorage.interface'; import { Cache } from '../decorator/cache'; import { Observable } from 'rxjs'; -import { delay, filter } from 'rxjs/operators'; +import { delay, filter, first } from 'rxjs/operators'; import { NgxStorageEvent } from '../utility/storage/storage-event'; import { Resource } from './resource'; const merge = require('lodash.merge'); @@ -68,7 +68,7 @@ export abstract class WebStorageService { filter((event: NgxStorageEvent) => { if (!key) { return true; } if (exactMatch) { - if (key.startsWith(Config.prefix)) { + if (!key.startsWith(Config.prefix)) { return event.key === key; } return event.key === Config.prefix + key; @@ -76,6 +76,7 @@ export abstract class WebStorageService { return event.key.indexOf(key) !== -1; } }), + first(), // take first event from events array delay(30) // event should come after actual data change and propagation ); } diff --git a/src/utility/storage/cookies-storage.ts b/src/utility/storage/cookies-storage.ts index 400378b..f213abb 100644 --- a/src/utility/storage/cookies-storage.ts +++ b/src/utility/storage/cookies-storage.ts @@ -1,7 +1,7 @@ import { Config, debug } from '../../config/index'; import { NgxStorage } from './storage'; import { StorageName, WebStorageUtility } from '../webstorage.utility'; -import { Observable, interval } from 'rxjs'; +import { interval } from 'rxjs'; export interface WebStorage extends Storage { setItem(key: string, data: string, expirationDate?: Date): void;