joo
'Spawn' multiple promises from the same module
I'm trying to use Deno for scripted npcs in a game, the main issue that the npc has to await user action so I've used a mpsc Channel for this with an async fn op which works fine. However since the npcs exists on the server side I need to be able to call the same npc multiple times on the same runtime.
My current test script looks like this
The problem I'm facing right now, I'd like to load the module once, remove the await in the end and then spawn multiple npc_actions while the event loop is running. So far I was only able to get a
Local
reference to the function, but when I call It I can no longer run the ev loop because the scope references the runtime.
What would be the best way to approach that?4 replies