cdl-sessionstorage
v0.0.5
Published
This is a simple session storage which is developed using javascript.
Downloads
13
Maintainers
Readme
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();
}
}