Skip to content
Snippets Groups Projects
Commit ef2e9fda authored by David Noah Donges's avatar David Noah Donges
Browse files

Add DataStoreService

Added service handling local data. Use this service so we can change the used technology (cookie, local storage, ..) easily.
parent 40a1281b
No related merge requests found
......@@ -64,6 +64,7 @@ import { CreatorHomeScreenComponent } from './creator-home-screen/creator-home-s
import { CreateCommentComponent } from './create-comment/create-comment.component';
import { CommentService } from './comment.service';
import { ParticipantHomeScreenComponent } from './participant-home-screen/participant-home-screen.component';
import { DataStoreService } from './data-store.service';
@NgModule({
declarations: [
......@@ -138,6 +139,7 @@ import { ParticipantHomeScreenComponent } from './participant-home-screen/partic
NotificationService,
AuthenticationService,
AuthenticationGuard,
DataStoreService,
RoomService,
CommentService
],
......
import { TestBed, inject } from '@angular/core/testing';
import { DataStoreService } from './data-store.service';
describe('DataStoreService', () => {
beforeEach(() => {
TestBed.configureTestingModule({
providers: [DataStoreService]
});
});
it('should be created', inject([DataStoreService], (service: DataStoreService) => {
expect(service).toBeTruthy();
}));
});
import { Injectable } from '@angular/core';
/**
* Service for storing local user data.
* Use this service to allow switching between localStorage, cookies, .. easily.
*/
@Injectable()
export class DataStoreService {
has(key: string): boolean {
return key in localStorage;
}
get(key: string): string {
return localStorage.getItem(key);
}
set(key: string, data: string) {
localStorage.setItem(key, data);
}
remove(key: string) {
localStorage.removeItem(key);
}
}
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment