ngx-webstorage

  • Version 13.0.1
  • Published
  • 183 kB
  • 1 dependency
  • MIT license

Install

npm i ngx-webstorage
yarn add ngx-webstorage
pnpm add ngx-webstorage

Overview

This library provides an easy to use service to manage the web storages (local and session) from your Angular application. It provides also two decorators to synchronize the component attributes and the web storages.

Index

Variables

variable InvalidStrategyError

const InvalidStrategyError: string;

    variable LIB_CONFIG

    const LIB_CONFIG: InjectionToken<NgxWebstorageConfiguration>;

      variable LOCAL_STORAGE

      const LOCAL_STORAGE: InjectionToken<WebStorage>;

        variable SESSION_STORAGE

        const SESSION_STORAGE: InjectionToken<WebStorage>;

          variable STORAGE_STRATEGIES

          const STORAGE_STRATEGIES: InjectionToken<StorageStrategy<any>>;

            variable StorageStrategyStubName

            const StorageStrategyStubName: string;

              Functions

              function appInit

              appInit: (
              index: StrategyIndex
              ) => () => { [name: string]: StorageStrategy<any> };

                function LocalStorage

                LocalStorage: (
                key?: string,
                defaultValue?: any
                ) => (prototype: any, propName: any) => void;

                  function SessionStorage

                  SessionStorage: (
                  key?: string,
                  defaultValue?: any
                  ) => (prototype: any, propName: any) => void;

                    Classes

                    class AsyncStorage

                    class AsyncStorage implements StorageService {}

                      constructor

                      constructor(strategy: StorageStrategy<any>);

                        property strategy

                        protected strategy: StorageStrategy<any>;

                          method clear

                          clear: (key?: string) => Observable<void>;

                            method getStrategyName

                            getStrategyName: () => string;

                              method observe

                              observe: (key: string) => Observable<any>;

                                method retrieve

                                retrieve: (key: string) => Observable<any>;

                                  method store

                                  store: (key: string, value: any) => Observable<any>;

                                    class CompatHelper

                                    class CompatHelper {}

                                      method isStorageAvailable

                                      static isStorageAvailable: (storage: WebStorage) => boolean;

                                        class InMemoryStorageStrategy

                                        class InMemoryStorageStrategy implements StorageStrategy<any> {}

                                          constructor

                                          constructor(cache: StrategyCacheService);

                                            property cache

                                            protected cache: StrategyCacheService;

                                              property isAvailable

                                              isAvailable: boolean;

                                                property keyChanges

                                                readonly keyChanges: Subject<string>;

                                                  property name

                                                  readonly name: string;

                                                    property ɵfac

                                                    static ɵfac: i0.ɵɵFactoryDeclaration<InMemoryStorageStrategy, never>;

                                                      property ɵprov

                                                      static ɵprov: i0.ɵɵInjectableDeclaration<InMemoryStorageStrategy>;

                                                        property strategyName

                                                        static readonly strategyName: string;

                                                          method clear

                                                          clear: () => Observable<void>;

                                                            method del

                                                            del: (key: string) => Observable<void>;

                                                              method get

                                                              get: (key: string) => Observable<any>;

                                                                method set

                                                                set: (key: string, value: any) => Observable<any>;

                                                                  class LocalStorageService

                                                                  class LocalStorageService extends SyncStorage {}

                                                                    class LocalStorageStrategy

                                                                    class LocalStorageStrategy extends BaseSyncStorageStrategy {}

                                                                      constructor

                                                                      constructor(
                                                                      storage: WebStorage,
                                                                      cache: StrategyCacheService,
                                                                      platformId: any,
                                                                      zone: NgZone
                                                                      );

                                                                        property cache

                                                                        protected cache: StrategyCacheService;

                                                                          property name

                                                                          readonly name: string;

                                                                            property ɵfac

                                                                            static ɵfac: i0.ɵɵFactoryDeclaration<LocalStorageStrategy, never>;

                                                                              property ɵprov

                                                                              static ɵprov: i0.ɵɵInjectableDeclaration<LocalStorageStrategy>;

                                                                                property platformId

                                                                                protected platformId: any;

                                                                                  property storage

                                                                                  protected storage: WebStorage;

                                                                                    property strategyName

                                                                                    static readonly strategyName: string;

                                                                                      property zone

                                                                                      protected zone: NgZone;

                                                                                        method listenExternalChanges

                                                                                        protected listenExternalChanges: () => void;

                                                                                          class NgxWebstorageModule

                                                                                          class NgxWebstorageModule {}

                                                                                            constructor

                                                                                            constructor(index: StrategyIndex, config: NgxWebstorageConfiguration);

                                                                                              property ɵfac

                                                                                              static ɵfac: i0.ɵɵFactoryDeclaration<
                                                                                              NgxWebstorageModule,
                                                                                              [null, { optional: true }]
                                                                                              >;

                                                                                                property ɵinj

                                                                                                static ɵinj: i0.ɵɵInjectorDeclaration<NgxWebstorageModule>;

                                                                                                  property ɵmod

                                                                                                  static ɵmod: i0.ɵɵNgModuleDeclaration<NgxWebstorageModule, never, never, never>;

                                                                                                    method forRoot

                                                                                                    static forRoot: (
                                                                                                    config?: NgxWebstorageConfiguration
                                                                                                    ) => ModuleWithProviders<NgxWebstorageModule>;

                                                                                                      class SessionStorageService

                                                                                                      class SessionStorageService extends SyncStorage {}

                                                                                                        class SessionStorageStrategy

                                                                                                        class SessionStorageStrategy extends BaseSyncStorageStrategy {}

                                                                                                          constructor

                                                                                                          constructor(
                                                                                                          storage: WebStorage,
                                                                                                          cache: StrategyCacheService,
                                                                                                          platformId: any,
                                                                                                          zone: NgZone
                                                                                                          );

                                                                                                            property cache

                                                                                                            protected cache: StrategyCacheService;

                                                                                                              property name

                                                                                                              readonly name: string;

                                                                                                                property ɵfac

                                                                                                                static ɵfac: i0.ɵɵFactoryDeclaration<SessionStorageStrategy, never>;

                                                                                                                  property ɵprov

                                                                                                                  static ɵprov: i0.ɵɵInjectableDeclaration<SessionStorageStrategy>;

                                                                                                                    property platformId

                                                                                                                    protected platformId: any;

                                                                                                                      property storage

                                                                                                                      protected storage: WebStorage;

                                                                                                                        property strategyName

                                                                                                                        static readonly strategyName: string;

                                                                                                                          property zone

                                                                                                                          protected zone: NgZone;

                                                                                                                            method listenExternalChanges

                                                                                                                            protected listenExternalChanges: () => void;

                                                                                                                              class StorageStrategyStub

                                                                                                                              class StorageStrategyStub implements StorageStrategy<any> {}

                                                                                                                                constructor

                                                                                                                                constructor(name?: string);

                                                                                                                                  property isAvailable

                                                                                                                                  readonly isAvailable: boolean;

                                                                                                                                    property keyChanges

                                                                                                                                    readonly keyChanges: Subject<string>;

                                                                                                                                      property name

                                                                                                                                      readonly name: string;

                                                                                                                                        property store

                                                                                                                                        store: any;

                                                                                                                                          method clear

                                                                                                                                          clear: () => Observable<void>;

                                                                                                                                            method del

                                                                                                                                            del: (key: string) => Observable<void>;

                                                                                                                                              method get

                                                                                                                                              get: (key: string) => Observable<any>;

                                                                                                                                                method set

                                                                                                                                                set: (key: string, value: any) => Observable<any>;

                                                                                                                                                  class StorageStub

                                                                                                                                                  class StorageStub implements WebStorage {}

                                                                                                                                                    property length

                                                                                                                                                    readonly length: number;

                                                                                                                                                      property store

                                                                                                                                                      store: { [prop: string]: any };

                                                                                                                                                        method clear

                                                                                                                                                        clear: () => void;

                                                                                                                                                          method getItem

                                                                                                                                                          getItem: (key: string) => string | null;

                                                                                                                                                            method key

                                                                                                                                                            key: (index: number) => string | null;

                                                                                                                                                              method removeItem

                                                                                                                                                              removeItem: (key: string) => void;

                                                                                                                                                                method setItem

                                                                                                                                                                setItem: (key: string, value: string) => void;

                                                                                                                                                                  class StrategyCacheService

                                                                                                                                                                  class StrategyCacheService {}

                                                                                                                                                                    property caches

                                                                                                                                                                    protected caches: { [name: string]: StrategyCache };

                                                                                                                                                                      property ɵfac

                                                                                                                                                                      static ɵfac: i0.ɵɵFactoryDeclaration<StrategyCacheService, never>;

                                                                                                                                                                        property ɵprov

                                                                                                                                                                        static ɵprov: i0.ɵɵInjectableDeclaration<StrategyCacheService>;

                                                                                                                                                                          method clear

                                                                                                                                                                          clear: (strategyName: string) => void;

                                                                                                                                                                            method del

                                                                                                                                                                            del: (strategyName: string, key: string) => void;

                                                                                                                                                                              method get

                                                                                                                                                                              get: (strategyName: string, key: string) => any;

                                                                                                                                                                                method getCacheStore

                                                                                                                                                                                protected getCacheStore: (strategyName: string) => StrategyCache;

                                                                                                                                                                                  method set

                                                                                                                                                                                  set: (strategyName: string, key: string, value: any) => void;

                                                                                                                                                                                    class StrategyIndex

                                                                                                                                                                                    class StrategyIndex {}

                                                                                                                                                                                      constructor

                                                                                                                                                                                      constructor(strategies: StorageStrategy<any>[]);

                                                                                                                                                                                        property index

                                                                                                                                                                                        static index: { [name: string]: StorageStrategy<any> };

                                                                                                                                                                                          property ɵfac

                                                                                                                                                                                          static ɵfac: i0.ɵɵFactoryDeclaration<StrategyIndex, [{ optional: true }]>;

                                                                                                                                                                                            property ɵprov

                                                                                                                                                                                            static ɵprov: i0.ɵɵInjectableDeclaration<StrategyIndex>;

                                                                                                                                                                                              property registration$

                                                                                                                                                                                              readonly registration$: Subject<string>;

                                                                                                                                                                                                property strategies

                                                                                                                                                                                                protected strategies: StorageStrategy<any>[];

                                                                                                                                                                                                  method clear

                                                                                                                                                                                                  static clear: (name?: string) => void;

                                                                                                                                                                                                    method get

                                                                                                                                                                                                    static get: (name: string) => StorageStrategy<any>;

                                                                                                                                                                                                      method getStrategy

                                                                                                                                                                                                      getStrategy: (name: string) => StorageStrategy<any>;

                                                                                                                                                                                                        method hasRegistredStrategies

                                                                                                                                                                                                        static hasRegistredStrategies: () => boolean;

                                                                                                                                                                                                          method indexStrategies

                                                                                                                                                                                                          indexStrategies: () => void;

                                                                                                                                                                                                            method indexStrategy

                                                                                                                                                                                                            indexStrategy: (
                                                                                                                                                                                                            name: string,
                                                                                                                                                                                                            overrideIfExists?: boolean
                                                                                                                                                                                                            ) => StorageStrategy<any>;

                                                                                                                                                                                                              method isStrategyRegistered

                                                                                                                                                                                                              static isStrategyRegistered: (name: string) => boolean;

                                                                                                                                                                                                                method register

                                                                                                                                                                                                                register: (
                                                                                                                                                                                                                name: string,
                                                                                                                                                                                                                strategy: StorageStrategy<any>,
                                                                                                                                                                                                                overrideIfExists?: boolean
                                                                                                                                                                                                                ) => void;

                                                                                                                                                                                                                  method set

                                                                                                                                                                                                                  static set: (name: string, strategy: any) => void;

                                                                                                                                                                                                                    class SyncStorage

                                                                                                                                                                                                                    class SyncStorage implements StorageService {}

                                                                                                                                                                                                                      constructor

                                                                                                                                                                                                                      constructor(strategy: StorageStrategy<any>);

                                                                                                                                                                                                                        property strategy

                                                                                                                                                                                                                        protected strategy: StorageStrategy<any>;

                                                                                                                                                                                                                          method clear

                                                                                                                                                                                                                          clear: (key?: string) => void;

                                                                                                                                                                                                                            method getStrategyName

                                                                                                                                                                                                                            getStrategyName: () => string;

                                                                                                                                                                                                                              method observe

                                                                                                                                                                                                                              observe: (key: string) => Observable<any>;

                                                                                                                                                                                                                                method retrieve

                                                                                                                                                                                                                                retrieve: (key: string) => any;

                                                                                                                                                                                                                                  method store

                                                                                                                                                                                                                                  store: (key: string, value: any) => any;

                                                                                                                                                                                                                                    Interfaces

                                                                                                                                                                                                                                    interface StorageStrategy

                                                                                                                                                                                                                                    interface StorageStrategy<T> {}

                                                                                                                                                                                                                                      property isAvailable

                                                                                                                                                                                                                                      readonly isAvailable: boolean;

                                                                                                                                                                                                                                        property keyChanges

                                                                                                                                                                                                                                        readonly keyChanges: Subject<string>;

                                                                                                                                                                                                                                          property name

                                                                                                                                                                                                                                          readonly name: string;

                                                                                                                                                                                                                                            method clear

                                                                                                                                                                                                                                            clear: () => Observable<void>;

                                                                                                                                                                                                                                              method del

                                                                                                                                                                                                                                              del: (key: string) => Observable<void>;

                                                                                                                                                                                                                                                method get

                                                                                                                                                                                                                                                get: (key: string) => Observable<T>;

                                                                                                                                                                                                                                                  method set

                                                                                                                                                                                                                                                  set: (key: string, value: T) => Observable<T>;

                                                                                                                                                                                                                                                    interface StrategyCache

                                                                                                                                                                                                                                                    interface StrategyCache {}

                                                                                                                                                                                                                                                      index signature

                                                                                                                                                                                                                                                      [key: string]: any;

                                                                                                                                                                                                                                                        Enums

                                                                                                                                                                                                                                                        enum StorageStrategies

                                                                                                                                                                                                                                                        enum StorageStrategies {
                                                                                                                                                                                                                                                        Local = 'local_strategy',
                                                                                                                                                                                                                                                        Session = 'session_strategy',
                                                                                                                                                                                                                                                        InMemory = 'in_memory_strategy',
                                                                                                                                                                                                                                                        }

                                                                                                                                                                                                                                                          member InMemory

                                                                                                                                                                                                                                                          InMemory = 'in_memory_strategy'

                                                                                                                                                                                                                                                            member Local

                                                                                                                                                                                                                                                            Local = 'local_strategy'

                                                                                                                                                                                                                                                              member Session

                                                                                                                                                                                                                                                              Session = 'session_strategy'

                                                                                                                                                                                                                                                                Package Files (19)

                                                                                                                                                                                                                                                                Dependencies (1)

                                                                                                                                                                                                                                                                Dev Dependencies (0)

                                                                                                                                                                                                                                                                No dev dependencies.

                                                                                                                                                                                                                                                                Peer Dependencies (2)

                                                                                                                                                                                                                                                                Badge

                                                                                                                                                                                                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                                                                                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/ngx-webstorage.

                                                                                                                                                                                                                                                                • Markdown
                                                                                                                                                                                                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/ngx-webstorage)
                                                                                                                                                                                                                                                                • HTML
                                                                                                                                                                                                                                                                  <a href="https://www.jsdocs.io/package/ngx-webstorage"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>