Hi, I’m currently diving into Promises, I had a rough time grasping its API but I’m fully capable now. However, its usage is unclear to me, is there anything else it can offer besides facilitating asynchronous tasks that contain a delay or implementing it in an “unsafe” thread (For example an attack but the player can die in between its execution, so we need to cancel the promise).
Also, are Promises performant ? Is it redundant when I can use other global luau tasks to accomplish the same thing ?
How exactly are they performant ? I read through the source code briefly and they still seemed to create new threads using coroutines (Which is why they can accomplish asynchronization), and a lot
(I mean a lot) of methods / fields attached to the promise. Furthermore as the documentation stated for the :andThen() method:
Chains onto an existing Promise and returns a new Promise.
Which in turn creates another thread. My presumption is that, depending on the amount of workload put onto one single thread, it is more performant to spread (Fork / join) those work amongst others.
Just a theory!
Edit: Still need some help and clarification on this topic, thanks.