Comments (6)
Could you elaborate? It's not clear to me what you are trying to achieve and how Q is involved in it
from q.
Could you elaborate? It's not clear to me what you are trying to achieve and how Q is involved in it
That's my problem with this document design/README.md.
from q.
If you don't call ref on the callback value, the callback might not return a promise and then you wouldn't be able to call p.then(...).then(...)
from q.
If you don't call ref on the callback value, the callback might not return a promise and then you wouldn't be able to call p.then(...).then(...)
I try only to use "callback(value)". it would be able to call p.then(...).then(...)
https://jsbin.com/cozuluxido/3/edit?html,js,console,output
Can you provide an example where it doesn't work๏ผ
from q.
p.then(() => 1)
would return 1, would it not?
Of course, there is a school of thought that promises should be strict monads, in which case, the author of the callback would be obliged to wrap/lift the return value in order to satisfy the type of then
(which would decompose into map
and flatMap
).
So p.then(() => ref(1))
would return a promise.
from q.
p.then(() => 1)
would return 1, would it not?Of course, there is a school of thought that promises should be strict monads, in which case, the author of the callback would be obliged to wrap/lift the return value in order to satisfy the type of
then
(which would decompose intomap
andflatMap
).So
p.then(() => ref(1))
would return a promise.
promise: {
then: function (_callback) {
let result = defer();
let callback = function (value) {
result.resolve(_callback(value));
};
if (pending) {
pending.push(callback);
} else {
value.then(callback);
}
return result.promise;
}
}
So p.then(() => 1) would return a promise.
There is an example on https://jsbin.com/cozuluxido/3/edit?html,js,console,output
from q.
Related Issues (20)
- Using jQuery v3+, Q($.ajax) promise returned doesn't seem to resolve HOT 2
- unhandledRejection does not provide promise.stack HOT 1
- Is it possible to use a native Promise object with q ? HOT 1
- async function giving error HOT 1
- Q.allSettled returning unhandled rejection promises HOT 3
- Question : Global Error handling in Promise HOT 2
- Issues with Promise prototype. HOT 1
- Is Q a superset of a native Promise? HOT 4
- How do u like await? HOT 1
- Invalid token q.js?v=1588706333081:854 Invalid token HOT 1
- Google Analytics HOT 7
- Safari drops ticks for backgrounded tasks iOS 14 HOT 13
- Minified release?
- The q4 and after is so hard to understand HOT 1
- In v2, not v1, package.json uses deprecated form of license {} HOT 5
- Add warning and recommend native promises HOT 1
- How can i convert an existing promise to a callback in Node.js ? HOT 1
- Need 'qs' version upadted to latest version to resolve Security Vulnerabilities HOT 2
- rasamaha
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 q.