Comments (3)
Why?
from roblox-lua-promise.
Why?
I think task.defer
is better suited for what Promise.defer
needs to accomplish -- the point is to simply resume a Promise as soon as possible, but not immediately, so resuming in the next frame when you can resume within the next invocation point (now) doesn't seem reasonable.
from roblox-lua-promise.
Why?
Here's a few reasons:
- Resumption happens same-frame (generally just at the end of the frame afaik) which gaurantees ordering across frames
- Guaranteed to have good task scheduler behaviour (regarding task.cancel)
- Developer expectations (given the similar naming, you would expect them to both have the same or similar behaviour)
One thing to consider:
- Deferrals inside of deferrals (e.g. a
Promise.defer
resulting from aPromise.defer
) will happen at the next entry-point but the next entry-point is already the current one - The engine has a limit to the number of times you can re-enter a defer point, so the above limits the depth of these calls, thus, you would need special logic to handle that (if you wanted to support defers inside of defers)
P.s. task.defer
like all of the other task methods additionally works with threads, so the following is a sufficient replacement for a :Wait()
:
task.defer(coroutine.running())
coroutine.yield()
from roblox-lua-promise.
Related Issues (20)
- Objects with an "andThen" function are treated as Promises HOT 9
- Promise:finally counts as a consumer, but it probably shouldn't
- Queued callbacks from a cancelled sub-promise should not be run
- Little typo in :expect() documentation
- Use coroutine.close on cancelled promise threads
- Promise.fold does not return correct value if there is an unresolved Promise in the passed list
- Syntax error in documentation example
- Implement Typings For Strict-Typing Luau Users HOT 7
- Unhandled Promise Rejection warning HOT 6
- coroutine.close issue HOT 2
- retryWithDelay signature is wrong
- Stabilize source field
- Promise wally package throws error "Access is denied. (os error 5)" HOT 1
- Cannot publish any library HOT 1
- Promise.all should not error for non-promise input values HOT 1
- Document the Error object and all of its members
- Promise.fromEvent as command HOT 1
- The auto-filling doesn't work? HOT 1
- Error in finally handler does not propagate to subsequent catch after a :timeout HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from roblox-lua-promise.