import { Injectable } from '@angular/core';

type IStateItem = {
    data: any;
};

@Injectable({
    providedIn: 'root',
})

export class StateService {
    private stateMap = new Map<string, IStateItem>();

    set(key: string, data: any) {
        this.stateMap.set(key, { data });
    }

    get(key: string) {
        const value = this.stateMap.get(key);
        return value?.data;
    }

    delete(key: string) {
        this.stateMap.delete(key);
    }
}
