Похожие чаты

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 ответов

16 просмотров

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

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

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

30500 за редактор? )
Владимир
47
а через ESC-код ?
Alexey Kulakov
29
Anyone knows where there are some instructions or discort about failed bridge transactions ?
Jochem
21
Чёт не понял, я ж правильной функцией воспользовался чтобы вывести отладочную информацию? но что-то она не ловится
notme
18
Привет)) уже кажется эту тему перемусолили, но вот я так и не понял. Я сейчас сижу на 27дюймов 2к мониторе. На Актуальной макоси, если я куплю 27д 4к монитор: - будет ли изобр...
Vladislav Piskunov
16
Also, why can’t the community have a vote/ say when it comes to initiatives like buybacks. Isn’t the point of crypto decentralisation? Don’t we deserve input as long term supp...
👨🏽‍🦰
13
any reference of this implementation?
BitBuddha
29
Страшнейшая правда про списки ЦБ. С первых дней жизни P2P сферы, молодые человеки, начитавшись законодательной базы и "внутренних" документов, решили, что им противостоит сер...
Foxcool
3
У меня есть функция где происходит это: write_bit(buffer, 1); write_bit(buffer, 0); write_bit(buffer, 1); write_bit(buffer, 1); write_bit(buffer, 1); w...
~
14
Hi guys, any problem with Pulsebrige? Trying to transfer from wETH to ETH. First it tells me to connect my metamask "through mobile app" not desktop. Then I did and confirmed ...
Snowflakecrypto
13
Карта сайта