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
f3880058
Commit
f3880058
authored
Aug 27, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Promise.defer is synchronous now
parent
fe46f81f
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 @
f3880058
...
...
@@ -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