mirror of
				https://github.com/mickael-kerjean/filestash.git
				synced 2025-11-04 13:35:46 +08:00 
			
		
		
		
	
		
			
				
	
	
		
			22 lines
		
	
	
		
			518 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
		
			518 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();
 |