The project has multiple modules that use the same polling logic, how to gracefully integrate together and can provide api for polling switches.

Page A/B/C shares the same data and needs to be polled. How to gracefully integrate multiple polls and provide controllable api

May.06,2022

do it based on the form of events. Npm events module is required

app.js, it is recommended to expose switch methods and listening event methods to the $vm prototype chain, so that each vue component can listen and switch

const EventEmitter = require('events').EventEmitter;
const ee = new EventEmitter();
let enableTimer = true;
let timer = setInterval(()=>{
    if(!enableTimer) {
        clearInterval(timer);
        timer = null;
        return;
    }
    ee.emit('ok'); // 
},60000);

/ / other JS

this.$ee.on('ok',()=>{}); // 
this.$ee.off('ok',()=>{}); // 
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e447ff-44aca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e447ff-44aca.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?