SHARE
TWEET

Untitled

a guest Jun 17th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. interface EComponents {
  2.   //...
  3. }
  4.  
  5. interface IComponent {
  6.   //...
  7. }
  8.  
  9. interface IComponentStore<T extends IComponent> {
  10.   setComponent(componentName: EComponents, component: T): void;
  11.   getComponents(componentName: EComponents): T[];
  12. }
  13.  
  14. class ComponentStore<T extends IComponent> implements IComponentStore<T> {
  15.   private components = new Map<EComponents, T[]>();
  16.  
  17.   setComponent(componentName: EComponents, component: T): void {
  18.     const components = this.components.get(componentName) || [];
  19.     this.components.set(componentName, [...components, component ]);
  20.   }
  21.  
  22.   getComponents(componentName: EComponents): T[] {
  23.     return this.components.get(componentName) || [];
  24.   }
  25. }
  26.      
  27. "use strict";
  28. class ComponentStore {
  29.     constructor() {
  30.         this.components = new Map();
  31.     }
  32.     setComponent(componentName, component) {
  33.         const components = this.components.get(componentName) || [];
  34.         this.components.set(componentName, [...components, component]);
  35.     }
  36.     getComponents(componentName) {
  37.         return this.components.get(componentName) || [];
  38.     }
  39. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top