Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rsvp.js
Commits
7052bff8
Commit
7052bff8
authored
Jun 29, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
prevent multiple promise resolution
This was handled for some code paths but not all.
parent
db474da1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
lib/rsvp/promise.js
lib/rsvp/promise.js
+10
-7
No files found.
lib/rsvp/promise.js
View file @
7052bff8
...
@@ -10,8 +10,7 @@ function isFunction(x){
...
@@ -10,8 +10,7 @@ function isFunction(x){
}
}
var
Promise
=
function
(
resolver
)
{
var
Promise
=
function
(
resolver
)
{
var
promise
=
this
,
var
promise
=
this
;
resolved
=
false
;
if
(
typeof
resolver
!==
'
function
'
)
{
if
(
typeof
resolver
!==
'
function
'
)
{
throw
new
TypeError
(
'
You must pass a resolver function as the sole argument to the promise constructor
'
);
throw
new
TypeError
(
'
You must pass a resolver function as the sole argument to the promise constructor
'
);
...
@@ -22,14 +21,10 @@ var Promise = function(resolver) {
...
@@ -22,14 +21,10 @@ var Promise = function(resolver) {
}
}
var
resolvePromise
=
function
(
value
)
{
var
resolvePromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
resolve
(
promise
,
value
);
resolve
(
promise
,
value
);
};
};
var
rejectPromise
=
function
(
value
)
{
var
rejectPromise
=
function
(
value
)
{
if
(
resolved
)
{
return
;
}
resolved
=
true
;
reject
(
promise
,
value
);
reject
(
promise
,
value
);
};
};
...
@@ -88,7 +83,9 @@ var invokeCallback = function(type, promise, callback, event) {
...
@@ -88,7 +83,9 @@ var invokeCallback = function(type, promise, callback, event) {
Promise
.
prototype
=
{
Promise
.
prototype
=
{
constructor
:
Promise
,
constructor
:
Promise
,
isFulfilled
:
undefined
,
isRejected
:
undefined
,
isResolved
:
undefined
,
then
:
function
(
done
,
fail
)
{
then
:
function
(
done
,
fail
)
{
this
.
off
(
'
error
'
,
onerror
);
this
.
off
(
'
error
'
,
onerror
);
...
@@ -158,6 +155,9 @@ function handleThenable(promise, value) {
...
@@ -158,6 +155,9 @@ function handleThenable(promise, value) {
}
}
function
fulfill
(
promise
,
value
)
{
function
fulfill
(
promise
,
value
)
{
if
(
promise
.
isResolved
){
return
;
}
promise
.
isResolved
=
true
;
config
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isFulfilled
=
true
;
promise
.
isFulfilled
=
true
;
...
@@ -166,6 +166,9 @@ function fulfill(promise, value) {
...
@@ -166,6 +166,9 @@ function fulfill(promise, value) {
}
}
function
reject
(
promise
,
value
)
{
function
reject
(
promise
,
value
)
{
if
(
promise
.
isResolved
){
return
;
}
promise
.
isResolved
=
true
;
config
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
isRejected
=
true
;
...
...
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