Похожие чаты

Hi. What is the best way to make two synchronous functions

that are being called and run one after another, into asynchronous functions?
for instance I have two functions named func1 and func2
and they both print their names on the console
I don't want it to always be func1 and then func2
I know I can make them run asynchronous by using setTimeout
just like this :

setTimeout(() => func1(), 0);
setTimeout(() => func2(), 0);

I'd like to know if there are other ways of doing it cleaner and more appropriate

11 ответов

18 просмотров

You need to edit the logic inside func1 and func2 to make the logic asynchronous

seems like it's ordered even with timeout

Willy- Автор вопроса
Thomas
You need to edit the logic inside func1 and func2 ...

the thing is that these two or more functions are used to inject html code into the DOM, I don't want the whole app to freeze because I call them one after another

Willy
the thing is that these two or more functions are ...

Maybe inside func1 you wait a bit everytime you add something to DOM with a setTimeout

Willy
the thing is that these two or more functions are ...

How much stuff are you adding to the DOM for it to take that much time

Willy- Автор вопроса
Thomas
Maybe inside func1 you wait a bit everytime you ad...

setTimeout fixes the problem all by itself however it makes the code somehow weird and odd

Willy- Автор вопроса
Thomas
Explain

look there is the static part of the app which is gonna be rendered from the server but the rest of app will be loaded from the client using javascript after the DOMContentLoaded event is triggered I'm also thinking of adding an object which has properties which hold true or false depending on the expected parts are loaded or not. and these functions that are meant to load the dynamic parts are going to be called at the very beginning of our DOMContentLoaded handler but the problem shows itself when you realize you can't make them work async by just the way you write the functions, the way they are processed in sync so they stay that way

Похожие вопросы

Обсуждают сегодня

Господа, а что сейчас вообще с рынком труда на делфи происходит? Какова ситуация?
Rꙮman Yankꙮvsky
29
А вообще, что может смущать в самой Julia - бы сказал, что нет единого стандартного подхода по многим моментам, поэтому многое выглядит как "хаки" и произвол. Короче говоря, с...
Viktor G.
2
@Benzenoid can you tell me the easiest, and safest way to bu.y HEX now?
Živa Žena
20
This is a question from my wife who make a fortune with memes 😂😂 About the Migration and Tokens: 1. How will the old tokens be migrated to the new $LGCYX network? What is th...
🍿 °anton°
2
30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
What is the Dex situation? Agora team started with the Pnetwork for their dex which helped them both with integration. It’s completed but as you can see from the Pnetwork ann...
Ben
1
Гайс, вопрос для разносторонее развитых: читаю стрим с юарта, нада выделять с него фреймы с определенной структурой, если ли чо готовое, или долбаться с ринг буффером? нада у...
Vitaly
9
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
@lozuk how do I get my phex copies of my ehex from a atomic wallet, to move to my rabby?
Justfrontin 👀
11
Карта сайта