Closed padolsey closed 11 years ago
This enables Operative to return a promise for async operatives (per native Promise API).
The branch has been tested with the slightlyoff/Promises polyfill.
E.g.
var combine = operative(function(foo, bar) { // Internally, use a Deferred: var deferred = this.deferred(); // A deferred has two methods: fulfill & reject: if (foo !== 'foo') { // Error (Rejection) deferred.reject('foo should be "foo"!'); } else { // Success (Filfillment) deferred.fulfill(foo + bar); } }); // Usage externally: var promise = combine('foo', 'bar'); promise.then(function(value) { // Fulfilled }, function(err) { // Rejected });
As you can see this branch also includes support for operative(Function) in additional to the already supported operative(Object).
operative(Function)
operative(Object)
Note that operative will only return a Promise IF:
operative.Promise
=== window.Promise
So, you'll have to include the aforementioned polyfill (or similar) to use this feature in most envs
Ref Issue #3, Issue #2
TODO: Review implementation in light of https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
This enables Operative to return a promise for async operatives (per native Promise API).
The branch has been tested with the slightlyoff/Promises polyfill.
E.g.
As you can see this branch also includes support for
operative(Function)
in additional to the already supportedoperative(Object)
.Note that operative will only return a Promise IF:
operative.Promise
is defined (by default=== window.Promise
)So, you'll have to include the aforementioned polyfill (or similar) to use this feature in most envs
Ref Issue #3, Issue #2