Project

General

Profile

1
import {Injectable} from "@angular/core";
2
import {Icon} from "./icons";
3

    
4
@Injectable({
5
  providedIn: 'root'
6
})
7
export class IconsService {
8
  
9
  private registry = new Map<string, string>();
10
  
11
  public registerIcons(icons: any[]): void {
12
    icons.forEach((icon: Icon) => this.registry.set(icon.name, icon.data));
13
  }
14
  
15
  public getIcon(iconName: string): string | undefined {
16
    if (!this.registry.has(iconName)) {
17
      console.warn(`We could not find Icon with the name ${iconName}, did you add it to the Icon registry?`);
18
    }
19
    return this.registry.get(iconName);
20
  }
21
}
(3-3/4)