Comments (5)
f1 running before f4 is a necessary result of the delays that the app adds. We insert a 0.5 second delay between each step to allow you to see what's going on. If you increase the timeout of f1 you should see that it runs correctly.
This is equivalent in non delayed code to doing:
setTimeout(f1, 1);
// some stuff
setTimeout(f4, 0);
if you did that you'd see f1 before f4
from loupe.
The interval issue is most likely a bug with my instrumentation code, as it's effectively emulating the browser behaviour, rather than using it directly. I'm probably not running clearInterval properly at all I suspect.
from loupe.
Thank you very much! I did increase the timeout of f1 and it runs correctly.
I'll try to read the code sometime to figure out the interval issue!
from loupe.
In the video and experience, setTimeout() is a function of window and include in the Web Apis. And I have a question,when setTimout(()=>, time) is waiting during time,whether is controlled by a browser thread,otherwise which part know the time has finished and push in the queue?
from loupe.
Are you sure this loupe works correctly? I read explanation above but)
setTimeout(function timeout() {
console.log("Timeout 1");
}, 3000); // or 300
setTimeout(function timeout() {
console.log("Timeout 2");
}, 1000); // or 100
setTimeout(function timeout() {
console.log("Timeout 3");
}, 2000); // or 200
setTimeout(function timeout() {
console.log("Timeout 4");
}, 1000); // or 100
I always get this sequence in the browser (Chrome). It's logical and correctly:
Timeout 2
Timeout 4
Timeout 3
Timeout 1
3s 1s 2s 1s But here is not correctly:
Timeout 2
Timeout 1
Timeout 3
Timeout 4
0.3s 0.1s 0.2s 0.1s Here is different and not correctly:
Timeout 1
Timeout 2
Timeout 3
Timeout 4
console.log('this is the start');
setTimeout(function cb1() {
console.log('this is a msg from callback 1');
});
console.log('this is just a message');
setTimeout(function cb2() {
console.log('this is a msg from callback 2');
}, 0);
console.log('this is the end');
Is it correctly works with setTimeout without 2nd argument (delay)? WebApis stores cb2()
after finish.
If I have both setTimeout with 180 ms delay I will see both in WebApis after finish. But if 1st timeout has 180ms and 2nd timeout has 400ms I will see only cb1
in webApis. example
from loupe.
Related Issues (20)
- gggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg
- Code Edit Bug HOT 2
- Support for async / await and promises HOT 5
- Promises are not supported HOT 5
- DOM manipulation
- Question, not issue :) HOT 8
- Clear Timeout is not Working as Expected Registered timeout executes even after HOT 2
- Not working with certain functions HOT 3
- Instructions going into call stack.
- Macrotask and microtask support?
- Stack not clear yet Event loop kicks in HOT 1
- Please provide "Fragment to fragment" exmple
- promise
- Add A Readme HOT 2
- License
- Don't work with IIFE
- can't edit the code to run HOT 2
- Code Edit issue HOT 9
- Cannot edit code, runs only template HOT 4
- different results for setTimeout HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from loupe.