faylang/fay-jquery — pull request #32 by johncant (2014-12-24 23:13:27+00:00)
Title: Deferred object

Hello, and Merry Christmas!

I've gone ahead and made a rudimentary implementation of jQuery's Deferred object. I've opened this PR mainly to ask for help in solving some of the issues that arose, and to show you what I've built so far, so please don't assume that it's ready to be merged yet. :smiley:

Things that are done:
- [x] Make new Deferred objects in Fay code
- [x] .fail() and .reject() on those objects
- [x] .done() and .resolve() on those objects, passing a single value
- [x] .always() handler
- [x] .then() to filter a single value
- [x] .state()
- [x] jQuery.when() with a homogeneous list
- [x] Promise, by pretending that it is a Deferrable
- [x] Many, many, tests.

Things that are not done:
- [ ] Multiple arguments to a callback
- [ ] Failure argument(s)
- [ ] Progress callbacks and notify
- [ ] Promise locked down at compile time
- [ ] Monad interface for chaining and binding Deferred(s)
- [ ] .when() with different types
- [ ] Pass JS this argument
- [ ] Make an existing object deferred, using resolve and reject.
- [ ] Deal with the Fay "bugs" I found
- [ ] Compatability with jQuery < 1.8

Notes:
- Probably should have used Null instead of Undefined to represent nothing being passed
- I might have found 2 "bugs" in Fay but they are hard to replicate - Comparing two arrays is always false (like JS), and a situation where a case statement on the type Text just defaulted to the first case every time. I can't replicate the second "bug" outside of src/JQuery/Deferred.hs

Hope this helps!