npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

ngx-persisting-data

v0.0.5

Published

This library allows you to persist variables globally in your Angular 2.x projects <br>

Readme

ngx-persisting-data

This library allows you to persist variables globally in your Angular 2.x projects

Contents

  1. Installation
  2. Basic Usage
  3. API Docs
  4. License

##Installation Install this library via npm running the following command:

$ npm i ngx-persisting-data

##Basic Usage Import the NgxPersistingDataModule into your module

import { NgxPersistingDataModule } from 'ngx-persisting-data'

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    NgxPersistingDataModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Now, inject the NgxPersistingData class in your component constructor

constructor(private persistingData: NgxPersistingData) {}

ngOnInit(): void {
    // Voilà, you can start using the library
    this.persistingData.set({
        namespace: 'bar',  
        context: StorageContext.Memory,
        key: 'foo', 
        value: 123.45
    });
    alert(this.persistingData.get('foo', 'bar', StorageContext.Memory));
  }

##API Docs

NgxPersistingData

The persistence object

Type: class

#####Methods | Name | Arguments | Returns | Description | | ------------- | ------------- | ------------- | ------------- | | get | (key: string, namespace: string, context: StorageContext) | any | Returns the current value of an existing item | | getAsObservable | (key: string, namespace: string, context: StorageContext) | Observable<IPersistingVariable> | Returns an observable linked to an existing item | | set | (conf: IPersistingDataConfigs) | Observable<IPersistingVariable> | Sets a new item | | remove | (key: string, namespace: string, context: StorageContext)| void | Removes the specified item | | clear | (context: StorageContext)| void | Removes the whole items in the specified storage context | | ifExists | (key: string, namespace: string, context: StorageContext, existing: (value?: any) => any, nonExisting?: () => any)| void | A shortcut if statement that evaluates the existence of the specified item and executes the corresponding callback | | bindProperty | (conf: IPersistingBindeablePropertyConfigs)| Observable<IPersistingVariable> | Overrides the get/set behavior of the specified component property and binds it to the storage | | bindProperties | (conf: IPersistingBindeablePropertiesConfigs)| void | Overrides the get/set behavior of multiple component properties and binds them to the storage |

StorageContext

Contains 3 different storage instances

Type: enum #####Properties | Name | Description | | ------------- | ------------- | | Session | Corresponds to sessionStorage | | Local | Corresponds to localStorage | | Memory | Corresponds to a temporary object |

####IPersistingDataConfigs Contains the settings to store a variable

Type: interface #####Properties | Name | Type | Optional | Description | | ------------- | ------------- | ------------- | ------------- | | key | string | no | Variable name | | context | StorageContext | yes | Selected instance to store the variable | | namespace | string | no | Namespace of the variable | | value | any or any[] | no | Variable value | | expiration | number | yes | Indicates the time to expire the variable | | onExpiration | (elem: IPersistingVariable) => any | yes | Callback that runs when the variable expires | | onChange | (elem: IPersistingVariable) => any | yes | Callback that runs every time the variable changes of value |

####IPersistingVariable Contains the properties of a stored variable

Type: interface #####Properties | Name | Type | Optional | Description | | ------------- | ------------- | ------------- | ------------- | | key | string | no | Variable name | | value | any or any[] | no | Variable value |

####IPersistingBindeablePropertyConfigs Contains the settings to bind a component property into the storage

Type: interface #####Properties | Name | Type | Optional | Description | | ------------- | ------------- | ------------- | ------------- | | property | string | no | Property name | | context | string | yes | Selected instance to store the property | | namespace | string | no | Namespace of the property | | component | object | no | Component instance | | onChange | (elem: IPersistingVaiable) => any | yes | Callback that runs every time the property changes of value |

####IPersistingBindeablePropertiesConfigs Contains the the settings to bind some component properties into the storage

Type: interface #####Properties | Name | Type | Optional | Description | | ------------- | ------------- | ------------- | ------------- | | properties | string[] | no | Property name | | context | string | yes | Selected instance to store the property | | namespace | string | no | Namespace of the property | | component | object | no | Component instance | | onChange | (elem: IPersistingVaiable) => any | yes | Callback that runs every time the property changes of value |

##License MIT