Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
jio_mebibou
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
Alexandra Rogova
jio_mebibou
Commits
fa7b93e0
Commit
fa7b93e0
authored
Aug 27, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Promise.defer is synchronous now
parent
65f14100
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
15 deletions
+25
-15
src/jio/core/Promise.js
src/jio/core/Promise.js
+25
-15
No files found.
src/jio/core/Promise.js
View file @
fa7b93e0
...
...
@@ -358,13 +358,18 @@ Promise.prototype.defer = function (callback) {
function
createSolver
()
{
return
{
"
resolve
"
:
function
()
{
var
array
;
if
(
that
.
_state
!==
"
resolved
"
&&
that
.
_state
!==
"
rejected
"
)
{
that
.
_state
=
"
resolved
"
;
that
.
_answers
=
arguments
;
that
.
_onResolve
.
forEach
(
function
(
callback
)
{
setTimeout
(
function
()
{
callback
.
apply
(
that
,
that
.
_answers
);
});
array
=
that
.
_onResolve
.
slice
();
setTimeout
(
function
()
{
var
i
;
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
try
{
array
[
i
].
apply
(
that
,
that
.
_answers
);
}
catch
(
ignore
)
{}
}
});
// free the memory
that
.
_onResolve
=
undefined
;
...
...
@@ -373,13 +378,18 @@ Promise.prototype.defer = function (callback) {
}
},
"
reject
"
:
function
()
{
var
array
;
if
(
that
.
_state
!==
"
resolved
"
&&
that
.
_state
!==
"
rejected
"
)
{
that
.
_state
=
"
rejected
"
;
that
.
_answers
=
arguments
;
that
.
_onReject
.
forEach
(
function
(
callback
)
{
setTimeout
(
function
()
{
callback
.
apply
(
that
,
that
.
_answers
);
});
array
=
that
.
_onReject
.
slice
();
setTimeout
(
function
()
{
var
i
;
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
try
{
array
[
i
].
apply
(
that
,
that
.
_answers
);
}
catch
(
ignore
)
{}
}
});
// free the memory
that
.
_onResolve
=
undefined
;
...
...
@@ -389,19 +399,19 @@ Promise.prototype.defer = function (callback) {
},
"
notify
"
:
function
()
{
if
(
that
.
_onProgress
)
{
var
answers
=
arguments
;
that
.
_onProgress
.
forEach
(
function
(
callback
)
{
callback
.
apply
(
that
,
answers
);
});
var
i
;
for
(
i
=
0
;
i
<
that
.
_onProgress
.
length
;
i
+=
1
)
{
try
{
that
.
_onProgress
[
i
].
apply
(
that
,
arguments
);
}
catch
(
ignore
)
{}
}
}
}
};
}
this
.
_state
=
"
running
"
;
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(
function
()
{
callback
(
createSolver
());
});
callback
(
createSolver
());
return
this
;
}
return
createSolver
();
...
...
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