update
This commit is contained in:
		@ -1,3 +1,5 @@
 | 
			
		||||
import {setEcoTimeout} from 'public/utils';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export default class {
 | 
			
		||||
    constructor(url, timeout) {
 | 
			
		||||
@ -30,7 +32,7 @@ export default class {
 | 
			
		||||
            if(promise != this.promise)
 | 
			
		||||
                return [];
 | 
			
		||||
 | 
			
		||||
            window.setTimeout(() => this.refresh(), this.timeout*1000)
 | 
			
		||||
            setEcoTimeout(() => this.refresh(), this.timeout*1000)
 | 
			
		||||
        })
 | 
			
		||||
        return promise
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										15
									
								
								assets/public/utils.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										15
									
								
								assets/public/utils.js
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,15 @@
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export function setEcoTimeout(func, ...args) {
 | 
			
		||||
    return setTimeout((...args) => {
 | 
			
		||||
        !document.hidden && func(...args)
 | 
			
		||||
    }, ...args)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export function setEcoInterval(func, ...args) {
 | 
			
		||||
    return setInterval((...args) => {
 | 
			
		||||
        !document.hidden && func(...args)
 | 
			
		||||
    }, ...args)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,7 @@
 | 
			
		||||
import Vue from 'vue';
 | 
			
		||||
 | 
			
		||||
import Model from 'public/model';
 | 
			
		||||
import {setEcoInterval} from 'public/utils';
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
export class Streamer extends Model {
 | 
			
		||||
@ -27,7 +28,7 @@ export class Source extends Model {
 | 
			
		||||
    constructor(data, {streamer=null, ...options}={}) {
 | 
			
		||||
        super(data, options);
 | 
			
		||||
        this.streamer = streamer;
 | 
			
		||||
        setInterval(() => this.tick(), 1000)
 | 
			
		||||
        setEcoInterval(() => this.tick(), 1000)
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    get isQueue() { return false; }
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user