export function collectWatchFn(callBack) { let status = ''; let arrFn = []; if (status === 'ing') { return; } return function (...args) { return new Promise(async (resolve, reject) => { if (status === 'ing') { //@ts-ignore arrFn.push((flag) => { if (flag) { resolve(true); } }); return; } status = 'ing'; //@ts-ignore await callBack.call(this, ...args); status = ''; if (arrFn.length) { arrFn.forEach((item) => { //@ts-ignore item(true); }); arrFn = []; } else { resolve(true); } }); }; }
标签:status,调用,arrFn,ts,之前,resolve,return,ing,等待 From: https://www.cnblogs.com/lvlvlv/p/17695262.html