Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Labels
Merge Requests
18
Merge Requests
18
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
nexedi
jio
Commits
544b9ac3
Commit
544b9ac3
authored
Aug 27, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Promise.js when onProgress callback added and assign callback(s) to item
parent
469cb81b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
5 deletions
+6
-5
src/jio/core/Promise.js
src/jio/core/Promise.js
+6
-5
No files found.
src/jio/core/Promise.js
View file @
544b9ac3
...
@@ -21,7 +21,7 @@ function Promise() {
...
@@ -21,7 +21,7 @@ function Promise() {
// when(value, callback, errback_opt)
// when(value, callback, errback_opt)
/**
/**
* when(item, [onSuccess], [onError]): Promise
* when(item, [onSuccess], [onError]
, [onProgress]
): Promise
*
*
* Return an item as first parameter of the promise answer. If item is of
* Return an item as first parameter of the promise answer. If item is of
* type Promise, the method will just return the promise. If item is of type
* type Promise, the method will just return the promise. If item is of type
...
@@ -34,16 +34,17 @@ function Promise() {
...
@@ -34,16 +34,17 @@ function Promise() {
* @param {Any} item The item to use
* @param {Any} item The item to use
* @param {Function} [onSuccess] The callback called on success
* @param {Function} [onSuccess] The callback called on success
* @param {Function} [onError] the callback called on error
* @param {Function} [onError] the callback called on error
* @param {Function} [onProgress] the callback called on progress
* @return {Promise} The promise
* @return {Promise} The promise
*/
*/
Promise
.
when
=
function
(
item
,
onSuccess
,
onError
)
{
Promise
.
when
=
function
(
item
,
onSuccess
,
onError
,
onProgress
)
{
if
(
item
instanceof
Promise
)
{
if
(
item
instanceof
Promise
)
{
return
item
;
return
item
.
done
(
onSuccess
).
fail
(
onError
).
progress
(
onProgress
)
;
}
}
if
(
typeof
Deferred
===
'
function
'
&&
item
instanceof
Deferred
)
{
if
(
typeof
Deferred
===
'
function
'
&&
item
instanceof
Deferred
)
{
return
item
.
promise
();
return
item
.
promise
()
.
done
(
onSuccess
).
fail
(
onError
).
progress
(
onProgress
)
;
}
}
var
p
=
new
Promise
().
done
(
onSuccess
).
fail
(
onError
);
var
p
=
new
Promise
().
done
(
onSuccess
).
fail
(
onError
)
.
progress
(
onProgress
)
;
p
.
defer
().
resolve
(
item
);
p
.
defer
().
resolve
(
item
);
return
p
;
return
p
;
};
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment