Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 4 commits
  • 7 files changed
  • 0 commit comments
  • 1 contributor
Commits on Apr 02, 2012
@ThomasBurleson ThomasBurleson Merge branch 'refs/heads/master' into develop/promise 06a75e8
Commits on Apr 04, 2012
@ThomasBurleson ThomasBurleson Added `requires` config to Promises
Added requires : [ …] configurations to
- DeferredUtils.coffee
- Promise.coffee
9472050
Commits on Apr 05, 2012
@ThomasBurleson ThomasBurleson Added DeferredUtils::cancelled()
Added cancelled() static method to create a deferred instance that is immediately cancelled.
92d29ba
@ThomasBurleson ThomasBurleson Merge branch 'refs/heads/develop/promise' 1c8fae9
View
51 build/deft-all.js
@@ -741,6 +741,7 @@ Open source under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
Ext.define('Deft.promise.Promise', {
alternateClassName: ['Deft.Promise'],
+ requires: ['Deft.promise.Deferred'],
statics: {
/**
Returns a new {@link Deft.promise.Promise} with the specified callbacks registered to be called:
@@ -915,6 +916,7 @@ Open source under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
*/
Ext.define('Deft.util.DeferredUtils', {
+ requires: ['Deft.promise.Deferred', 'Deft.promise.Promise'],
statics: {
/**
Build an instance of a Deferred wrapped around a callback or value
@@ -935,6 +937,19 @@ Open source under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
return dfd;
},
/**
+ Build an instance of a Deferred that is immediately cancelled.
+ This is useful for activity that fails to build an desired promise but the
+ activity watchers still expect a promise instance.
+
+ @param {string} reason Why has the promise been cancelled?
+ @return {Deft.promise.Promise} Promise, read-only instance
+ */
+ cancelled: function(reason) {
+ return this.defer(function(dfd) {
+ return dfd.cancel(reason);
+ }).promise();
+ },
+ /**
Returns a new {@link Deft.promise.Promise} for the specified function/continuation/value, after the specified delay time. If the argument is
a function, the response to the function invocation will be used to resolve the
Deferred.
@@ -1491,42 +1506,6 @@ Open source under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
@author Thomas Burleson
Consider the scenario where we get a promise for user details (loaded from server):
-
- function loadPage() {
-
- // Build proxy and operation
-
- var proxy = Ext.create('Ext.data.proxy.Ajax',
- {
- url : 'userDetails.php'
- }
- ),
- operation = Ext.create('Ext.data.Operation',
- {
- action : 'read',
- params : { id : 21323 }
- }
- );
-
- // Issue the Ajax/XHR request, then return
- // a promise to allow extra response notifications
-
- return proxy.doRequest( operation )
- .promise()
- .then (
- // intercept response and extract data
- function (response) {
- return (response.success) ?
- response.data :
- throw new Error("Call failed!");
- },
- // extract fault message
- function (fault){
- return fault.message;
- }
- );
-
- }
*/
Ext.define('Deft.overrides.fx.Anim', {
View
35 src/coffee/Deft/overrides/fx/Anim.coffee
@@ -3,41 +3,6 @@
Consider the scenario where we get a promise for user details (loaded from server):
- function loadPage() {
-
- // Build proxy and operation
-
- var proxy = Ext.create('Ext.data.proxy.Ajax',
- {
- url : 'userDetails.php'
- }
- ),
- operation = Ext.create('Ext.data.Operation',
- {
- action : 'read',
- params : { id : 21323 }
- }
- );
-
- // Issue the Ajax/XHR request, then return
- // a promise to allow extra response notifications
-
- return proxy.doRequest( operation )
- .promise()
- .then (
- // intercept response and extract data
- function (response) {
- return (response.success) ?
- response.data :
- throw new Error("Call failed!");
- },
- // extract fault message
- function (fault){
- return fault.message;
- }
- );
-
- }
###
Ext.define( 'Deft.overrides.fx.Anim',
View
1  src/coffee/Deft/promise/Promise.coffee
@@ -10,6 +10,7 @@ Open source under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
Ext.define( 'Deft.promise.Promise',
alternateClassName: [ 'Deft.Promise' ]
+ requires: [ 'Deft.promise.Deferred' ]
statics:
View
18 src/coffee/Deft/util/DeferredUtils.coffee
@@ -6,7 +6,7 @@
###
Ext.define( 'Deft.util.DeferredUtils',
-
+ requires: [ 'Deft.promise.Deferred', 'Deft.promise.Promise' ]
statics:
###*
@@ -26,6 +26,18 @@ Ext.define( 'Deft.util.DeferredUtils',
return dfd
+ ###*
+ Build an instance of a Deferred that is immediately cancelled.
+ This is useful for activity that fails to build an desired promise but the
+ activity watchers still expect a promise instance.
+
+ @param {string} reason Why has the promise been cancelled?
+ @return {Deft.promise.Promise} Promise, read-only instance
+ ###
+ cancelled : (reason) ->
+ return @defer( (dfd) ->
+ dfd.cancel( reason )
+ ).promise()
###*
Returns a new {@link Deft.promise.Promise} for the specified function/continuation/value, after the specified delay time. If the argument is
@@ -142,8 +154,8 @@ Ext.define( 'Deft.util.DeferredUtils',
# Callback invoked after the Ext.define() completes
->
# Alias shorthands
- Deft.defer = @defer
- Deft.wait = @wait
+ Deft.defer = @defer
+ Deft.wait = @wait
Deft.ajax = # methods for Ext.Ajax, Ext.proxy.*, etc
hookCallbacks : @hookRequestCallbacks
createCallback : @createOperationCallback
View
36 src/js/Deft/overrides/fx/Anim.js
@@ -3,42 +3,6 @@
@author Thomas Burleson
Consider the scenario where we get a promise for user details (loaded from server):
-
- function loadPage() {
-
- // Build proxy and operation
-
- var proxy = Ext.create('Ext.data.proxy.Ajax',
- {
- url : 'userDetails.php'
- }
- ),
- operation = Ext.create('Ext.data.Operation',
- {
- action : 'read',
- params : { id : 21323 }
- }
- );
-
- // Issue the Ajax/XHR request, then return
- // a promise to allow extra response notifications
-
- return proxy.doRequest( operation )
- .promise()
- .then (
- // intercept response and extract data
- function (response) {
- return (response.success) ?
- response.data :
- throw new Error("Call failed!");
- },
- // extract fault message
- function (fault){
- return fault.message;
- }
- );
-
- }
*/
(function() {
View
1  src/js/Deft/promise/Promise.js
@@ -13,6 +13,7 @@ Open source under the [MIT License](http://en.wikipedia.org/wiki/MIT_License).
Ext.define('Deft.promise.Promise', {
alternateClassName: ['Deft.Promise'],
+ requires: ['Deft.promise.Deferred'],
statics: {
/**
Returns a new {@link Deft.promise.Promise} with the specified callbacks registered to be called:
View
14 src/js/Deft/util/DeferredUtils.js
@@ -10,6 +10,7 @@
var __slice = Array.prototype.slice;
Ext.define('Deft.util.DeferredUtils', {
+ requires: ['Deft.promise.Deferred', 'Deft.promise.Promise'],
statics: {
/**
Build an instance of a Deferred wrapped around a callback or value
@@ -30,6 +31,19 @@
return dfd;
},
/**
+ Build an instance of a Deferred that is immediately cancelled.
+ This is useful for activity that fails to build an desired promise but the
+ activity watchers still expect a promise instance.
+
+ @param {string} reason Why has the promise been cancelled?
+ @return {Deft.promise.Promise} Promise, read-only instance
+ */
+ cancelled: function(reason) {
+ return this.defer(function(dfd) {
+ return dfd.cancel(reason);
+ }).promise();
+ },
+ /**
Returns a new {@link Deft.promise.Promise} for the specified function/continuation/value, after the specified delay time. If the argument is
a function, the response to the function invocation will be used to resolve the
Deferred.

No commit comments for this range

Something went wrong with that request. Please try again.