cdl-localstorage
TypeScript icon, indicating that this package has built-in type declarations

0.0.8 • Public • Published

Localstorage

This is a simple local storage which is developed using javascript.

Installation instruction

npm install cdl-localstorage --save

Instruction to use the package

How to use?

Please follow below instruction to implement local storage in your angular application.

//in module
import { LocalstorageModule } from 'cdl-localstorage'; 

imports: [
    LocalstorageModule
]

// In your component ts file

import { LocalstorageService } from 'cdl-localstorage';

First way to utilize service

// Extend service to utilize its functions

export class AppComponent extends LocalstorageService {

    constructor() {
        super();
    }

    ngOnInit() {
        //Set value in local storage by key value pair
        this.setValue(key, value);

        //Get value from local storage by key
        this.getValue(key);

        //Clear specific value in local storage by key
        this.clearValue(key);

        //Clear entire local storage
        this.clearAll();
    }
}

Second way to utilize service

// Initilize service to constructor

export class AppComponent {

    constructor(private localstorageService: LocalstorageService) {
        //TODO:
    }

    ngOnInit() {
        //Set value in local storage by key value pair
        this.localstorageService.setValue(key, value);

        //Get value from local storage by key
        this.localstorageService.getValue(key);
        
        //Clear specific value in local storage by key
        this.localstorageService.clearValue(key);
        
        //Clear entire local storage
        this.localstorageService.clearAll();
    }
}

Package Sidebar

Install

npm i cdl-localstorage

Weekly Downloads

0

Version

0.0.8

License

MIT

Unpacked Size

33.9 kB

Total Files

23

Last publish

Collaborators

  • rsolanki