ngx-webstorage

  • Version 22.0.0
  • Published
  • 98.4 kB
  • 1 dependency
  • MIT license

Install

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

Overview

Local and session storage services and decorators for Angular

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 LocalStorage

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

                function makeNgxWebstorageFeature

                makeNgxWebstorageFeature: <FeatureKind extends NgxWebstorageFeatureKind>(
                kind: FeatureKind,
                providers: Provider[]
                ) => NgxWebstorageFeature<FeatureKind>;

                  function provideNgxWebstorage

                  provideNgxWebstorage: (
                  ...features: NgxWebstorageFeature<NgxWebstorageFeatureKind>[]
                  ) => i0.EnvironmentProviders;
                  • Provide ngx-webstorage basic features.

                    - You can customise the configuration with the withConfiguration feature. - You can enable the LocalStorage features with the withLocalStorage feature. - You can enable the SessionStorage features with the withSessionStorage feature.

                    config { prefix: 'ngx-webstorage', separator: '|', caseSensitive: false }

                  function SessionStorage

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

                    function withLocalStorage

                    withLocalStorage: () => NgxWebstorageFeature<InternalNgxWebstorageFeatureKind.LocalStorage>;
                    • Provides everything necessary to use the LocalStorage features.

                    function withNgxWebstorageConfig

                    withNgxWebstorageConfig: (
                    config: NgxWebstorageConfiguration
                    ) => NgxWebstorageFeature<InternalNgxWebstorageFeatureKind.Config>;

                      function withSessionStorage

                      withSessionStorage: () => NgxWebstorageFeature<InternalNgxWebstorageFeatureKind.SessionStorage>;

                        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 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: StorageStrategy<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 InternalNgxWebstorageFeatureKind

                                                                                                                                                                                                                                                enum InternalNgxWebstorageFeatureKind {
                                                                                                                                                                                                                                                Config = 1,
                                                                                                                                                                                                                                                LocalStorage = 2,
                                                                                                                                                                                                                                                SessionStorage = 3,
                                                                                                                                                                                                                                                }

                                                                                                                                                                                                                                                  member Config

                                                                                                                                                                                                                                                  Config = 1

                                                                                                                                                                                                                                                    member LocalStorage

                                                                                                                                                                                                                                                    LocalStorage = 2

                                                                                                                                                                                                                                                      member SessionStorage

                                                                                                                                                                                                                                                      SessionStorage = 3

                                                                                                                                                                                                                                                        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'

                                                                                                                                                                                                                                                                Type Aliases

                                                                                                                                                                                                                                                                type NgxWebstorageFeature

                                                                                                                                                                                                                                                                type NgxWebstorageFeature<FeatureKind extends NgxWebstorageFeatureKind> = {
                                                                                                                                                                                                                                                                kind: FeatureKind;
                                                                                                                                                                                                                                                                providers: Provider[];
                                                                                                                                                                                                                                                                };

                                                                                                                                                                                                                                                                  type NgxWebstorageFeatureKind

                                                                                                                                                                                                                                                                  type NgxWebstorageFeatureKind = string | InternalNgxWebstorageFeatureKind;

                                                                                                                                                                                                                                                                    Package Files (1)

                                                                                                                                                                                                                                                                    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>