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
Hamza
jio
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
Show 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) {
...
@@ -358,13 +358,18 @@ Promise.prototype.defer = function (callback) {
function
createSolver
()
{
function
createSolver
()
{
return
{
return
{
"
resolve
"
:
function
()
{
"
resolve
"
:
function
()
{
var
array
;
if
(
that
.
_state
!==
"
resolved
"
&&
that
.
_state
!==
"
rejected
"
)
{
if
(
that
.
_state
!==
"
resolved
"
&&
that
.
_state
!==
"
rejected
"
)
{
that
.
_state
=
"
resolved
"
;
that
.
_state
=
"
resolved
"
;
that
.
_answers
=
arguments
;
that
.
_answers
=
arguments
;
that
.
_onResolve
.
forEach
(
function
(
callback
)
{
array
=
that
.
_onResolve
.
slice
();
setTimeout
(
function
()
{
setTimeout
(
function
()
{
callback
.
apply
(
that
,
that
.
_answers
);
var
i
;
});
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
try
{
array
[
i
].
apply
(
that
,
that
.
_answers
);
}
catch
(
ignore
)
{}
}
});
});
// free the memory
// free the memory
that
.
_onResolve
=
undefined
;
that
.
_onResolve
=
undefined
;
...
@@ -373,13 +378,18 @@ Promise.prototype.defer = function (callback) {
...
@@ -373,13 +378,18 @@ Promise.prototype.defer = function (callback) {
}
}
},
},
"
reject
"
:
function
()
{
"
reject
"
:
function
()
{
var
array
;
if
(
that
.
_state
!==
"
resolved
"
&&
that
.
_state
!==
"
rejected
"
)
{
if
(
that
.
_state
!==
"
resolved
"
&&
that
.
_state
!==
"
rejected
"
)
{
that
.
_state
=
"
rejected
"
;
that
.
_state
=
"
rejected
"
;
that
.
_answers
=
arguments
;
that
.
_answers
=
arguments
;
that
.
_onReject
.
forEach
(
function
(
callback
)
{
array
=
that
.
_onReject
.
slice
();
setTimeout
(
function
()
{
setTimeout
(
function
()
{
callback
.
apply
(
that
,
that
.
_answers
);
var
i
;
});
for
(
i
=
0
;
i
<
array
.
length
;
i
+=
1
)
{
try
{
array
[
i
].
apply
(
that
,
that
.
_answers
);
}
catch
(
ignore
)
{}
}
});
});
// free the memory
// free the memory
that
.
_onResolve
=
undefined
;
that
.
_onResolve
=
undefined
;
...
@@ -389,19 +399,19 @@ Promise.prototype.defer = function (callback) {
...
@@ -389,19 +399,19 @@ Promise.prototype.defer = function (callback) {
},
},
"
notify
"
:
function
()
{
"
notify
"
:
function
()
{
if
(
that
.
_onProgress
)
{
if
(
that
.
_onProgress
)
{
var
answers
=
arguments
;
var
i
;
that
.
_onProgress
.
forEach
(
function
(
callback
)
{
for
(
i
=
0
;
i
<
that
.
_onProgress
.
length
;
i
+=
1
)
{
callback
.
apply
(
that
,
answers
);
try
{
});
that
.
_onProgress
[
i
].
apply
(
that
,
arguments
);
}
catch
(
ignore
)
{}
}
}
}
}
}
};
};
}
}
this
.
_state
=
"
running
"
;
this
.
_state
=
"
running
"
;
if
(
typeof
callback
===
'
function
'
)
{
if
(
typeof
callback
===
'
function
'
)
{
setTimeout
(
function
()
{
callback
(
createSolver
());
callback
(
createSolver
());
});
return
this
;
return
this
;
}
}
return
createSolver
();
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