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
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Yaxel Perez
jio
Commits
787caa79
Commit
787caa79
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
393c799c
Changes
1
Hide 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 @
787caa79
...
@@ -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