-
I want to implement an let globals = lua.globals();
globals.set("some_work", lua.create_async_function(|_, ()| async move {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
Ok("Slept for 1 second".to_owned())
})?)?;
globals.set("await", lua.create_function(|_, (f, cb): (Function, Function)| {
// ...
})?)?; In Lua: await(some_work, function (ret)
print(ret) -- Prints "Slept for 1 second"
end) The Is there a way to achieve this without enabling the |
Beta Was this translation helpful? Give feedback.
Answered by
khvzak
Jul 5, 2025
Replies: 1 comment 5 replies
-
I'm not sure I understand the problem. Why you need |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You don't need to create
LocalSet
inside function, you can create it once, enter and use everywhere throughtask::spawn_local
.