Comments (12)
First, I would say I have failed to truly align with either; however, with that said. I am certainly closer to the JQuery.
For example Q.js uses catch, while I choose jquery's fail, primarily due to using it more often. What would be your opinion? Thinking about it now, I think catch actually makes more sense.
Additionally a few changes were made to align more with the nature of XQuery.
In regards to when, it is analogous to JQuery's when method or Q's all method, except unlike in Q.js, it accepts a mix of promises, raw values (static) or single arity functions, instead of just a sequence of promises. Its purpose is not around static vs non static, but around using multi arity functions in a pipeline.
For example:
let $phrase := 'Hello'
let $name := p:defer(api:getName(?), '23')
return
p:when(($phrase, $name))
=> p:then(function ($phrase , $name) { $phrase || $name });
Raw values are actually not supported due to oversight on my part in the current build out there. Ill fix that here quick, still recovering. ;0
There is a lot of stuff which doesn't transfer, or atleast need not, from javascript. For example, I don't have an any clause.
Thoughts?
from xq-promise.
I think I completely missed one piece of this pattern in this implementation and what you were eluding to. Basically I didn't account for a very important facet to this pattern, the returning of a promise from a callback. The idea labelled by Q as static or non static.
let $greet:= function ($name) {
let $greeting:= if($name = 'world') then $greet-world else $greet-non-world
return p:defer($greeting, $name)
}
let $promise := p:defer($greet, 'world')
return
$promise()
from xq-promise.
So with all this said, I think this implementation proofs the pattern works, but I implemented the pattern slightly wrong. I agree we should decide on a template, and follow it all the way.
Luckily, whatever we choose will be a trivial change to actually implement.
What is your preference?
from xq-promise.
Wholly crap... I can write this entirely in XQuery except fork and fork-join...
more to come...
from xq-promise.
I tend to APIs with lighter footprint (jQuery in this case). On the other hand, the only official spec is A+ (also ECMA6) and I just read on the jQuery blog that they have a patch for jQuery 3.0 to align it with the spec.
Soo, in the end I guess A+ would be a good choice.
from xq-promise.
Now having said that - A+ is only defining then
semantics. Q just added everything else on its own. So apart from then
there is no single source of truth...
from xq-promise.
So, ECMA defines more methods, as always Mozilla MDN on Promise is a good read.
Promise.all() Promise.prototype.catch() Promise.prototype.then() Promise.race() Promise.reject() Promise.resolve()
Offical ECMA 2016 Spec: https://tc39.github.io/ecma262/#sec-promise-objects
from xq-promise.
Thanks for the links! Now that the original library is converted to basically pure XQuery it will be easier to modify towards a goal of A+ coherence, at least as close as possible. I need to start with adding support for the reject callback. I think otherwise the conformance is rather close.
Not sure if the concepts of fufilled, pending, etc will apply with xquery...
from xq-promise.
The then
method should now behave like stated in the Offical ECMA 2016 Spec:
https://tc39.github.io/ecma262/#sec-promise-objects
With this, an additional overload accepts a reject callback. Additionally a fulfillment callback is not required. Multiple promises are also now supported.
Need to overhaul docs.
from xq-promise.
when
should be working as outlined for Q's all
method:
Use the Q function to turn the non-promise values into promises, or pass an array to Q.all to get back a promise for an array of the results.
Are you seeing it operation differently. If you can give me an example query which operates out of sync It might be helpful.
from xq-promise.
I'll soon add it to a project I am working on (for async image processing etc.) and tell you about my progress (or even add you to the repo)
from xq-promise.
Sounds interesting! Keep me posted.
from xq-promise.
Related Issues (16)
- Calling promise fails if worker takes more than one argument HOT 4
- fail should be provided a map with error information as well as arguments bound. HOT 3
- promise:fork HOT 24
- XML transformations cannot be parallelized HOT 1
- XPTY0004 issue with xq-promise 0.8.0 beta HOT 3
- Pass on arguments as array HOT 3
- Add support for EXPath packaging HOT 2
- Success callback called twice on failure
- When should pass non function items
- pure xquery implementation HOT 6
- Support for updates HOT 5
- Rewriting FOR Clause HOT 4
- Promise Module → Async Module? HOT 3
- Update docs to leverage xquery:fork-join
- xq-promise Terminology vs. JavaScript/jQuery
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 xq-promise.