import {Injectable} from "@angular/core"; import {Icon} from "./icons"; @Injectable({ providedIn: 'root' }) export class IconsService { private registry = new Map(); public registerIcons(icons: any[]): void { icons.forEach((icon: Icon) => this.registry.set(icon.name, icon.data)); } public getIcon(iconName: string): string | undefined { if (!this.registry.has(iconName)) { console.warn(`We could not find Icon with the name ${iconName}, did you add it to the Icon registry?`); } return this.registry.get(iconName); } }