Open LPGhatguy opened 6 years ago
You might want to take a look at my fork of the F3X Try library. The documentation is available here. I don't really like it though because it doesn't really have any specifications like Promises
does, so what it should do is really just whatever I thought GigsD4X may have told me one night. However, it does have a few cool things that might give you good ideas for this library. It wraps all calls in a coroutine, and tracks the traceback along the way. If you do somehow arrive upon an error, it will "compile" the tracebacks into a single error message. It also doesn't create a new Attempt
object internally, it reuses the same table object the entire time and simply changes the values accordingly.
If this promise implementation wrapped each callback in a coroutine instead of using
xpcall
, then wrapping APIs that yield wouldn't requirespawn
. It would also help guard against cases where users yield intentionally or otherwise.One thing to note is that we probably lose the ability to track errors after a yield has occurred. The current version bans yielding entirely, a previous version allowed it by virtue of using
pcall
, and this version would catch errors, but only if they occur before the first yield.