Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export class Popup {
  2.  
  3.     constructor(type, text) {
  4.         this.type = type;
  5.         this.text = text;
  6.         this.onDismiss = undefined;
  7.     }
  8.  
  9.     show() {
  10.         setTimeout(() => {
  11.             if(this.onDismiss) {
  12.                 // THIS IS THE CALLBACK. Passing PopupInstance
  13.                 this.onDismiss(this);    
  14.             }            
  15.         }, 3000);
  16.     }
  17.  
  18.     setOnDismiss(onDismiss) {
  19.         this.onDismiss = onDismiss;
  20.     }
  21.  
  22. }
  23.  
  24. export class PopupContainer {
  25.  
  26.     constructor() {
  27.         debugger;
  28.         this.popupArray = [];
  29.         debugger;
  30.     }
  31.  
  32.     addPopup(popup) {
  33.         popup.setOnDismiss(this.removePopup);
  34.         this.popupArray.push(popup);
  35.         debugger;
  36.     }
  37.  
  38.     removePopup(popup) {
  39.         debugger;
  40.         //HERE I NEED TO ACCESS TO popupArray
  41.         this.popupArray.slice(this.popupArray.find(popup), 1);
  42.     }
  43.  
  44.     get html() {
  45.         let html = 'not';
  46.         for(let i = 0; i < this.popupArray.length; i++) {
  47.             html += "<li>Allo</li>";
  48.         }
  49.         return html;
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement