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

0.0.5 • Public • Published

SessionStorage

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

Installation instruction

npm install cdl-sessionstorage --save

Instruction to use the package

How to use?

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

//in module
import { SessionstorageModule } from 'cdl-sessionstorage'; 

imports: [
    SessionstorageModule
]

// In your component ts file

import { SessionstorageService } from 'cdl-sessionstorage';

First way to utilize service

// Extend service to utilize its functions

export class AppComponent extends SessionstorageService {

    constructor() {
        super();
    }

    ngOnInit() {

        //Set value in session storage by key value pair
        this.setValue(key, value);

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

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

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

Second way to utilize service

// Initilize service to constructor

export class AppComponent {

    constructor(private sessionstorageService: SessionstorageService) {
        //TODO:
    }

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

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

Package Sidebar

Install

npm i cdl-sessionstorage

Weekly Downloads

2

Version

0.0.5

License

MIT

Unpacked Size

34.6 kB

Total Files

23

Last publish

Collaborators

  • rsolanki