Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Execute a function repeatedly when frame change.
- * @param {Function} func
- * @param {any} args
- * @return {stop} : Function to stop the loop
- */
- function frameLoop(func, ...args) {
- let loop = true;
- (async function execute() {
- await nextFrame();
- func(...args);
- if (loop) execute();
- })();
- return stop;
- function stop() {
- loop = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement