mirror of
				https://github.com/mickael-kerjean/filestash.git
				synced 2025-10-31 10:07:15 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			18 lines
		
	
	
		
			454 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			18 lines
		
	
	
		
			454 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| const Message = function (){
 | |
|     let fn = null;
 | |
| 
 | |
|     return {
 | |
|         send: function(text, type){
 | |
|             if(['info', 'success', 'error'].indexOf(type) === -1){ type = 'info'; }
 | |
|             if(!fn){ return window.setTimeout(() => this.send(text,type), 50); }
 | |
|             fn(text, type);
 | |
|             return Promise.resolve();
 | |
|         },
 | |
|         subscribe: function(_fn){
 | |
|             fn = _fn;
 | |
|         }
 | |
|     };
 | |
| };
 | |
| 
 | |
| export const notify = new Message();
 | 
