how to enable require to load modules in async ways #504
-
I am trying to enable require to load modules in async ways. My current approach is to register a sync searcher in the searchers table and have it return an async loader. Here is a simplified example of my code:
the answer is:
Is there a viable way to enable require to load modules in async ways as described? After some exploration, I found that directly waiting for async logic in sync code (for example, using futures::executor::block_on) is feasible. However, I am not sure if this is considered a good practice. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
You need to rewrite
It depends on your app logic, e.g. it's ok to block the thread if don't use async Lua glue. |
Beta Was this translation helpful? Give feedback.
You need to rewrite
require
function to make it async as well.See Lune example how they did it
It depends on your app logic, e.g. it's ok to block the thread if don't use async Lua glue.