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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
rsvp.js
Commits
fdaaddad
Commit
fdaaddad
authored
Nov 14, 2013
by
Romain Courteaud
🐙
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Cancelling RSVP.resolve should also cancel thenable.
parent
f11787e6
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
8 deletions
+66
-8
dist/commonjs/rsvp/resolve.js
dist/commonjs/rsvp/resolve.js
+11
-1
dist/rsvp-2.0.4.amd.js
dist/rsvp-2.0.4.amd.js
+11
-1
dist/rsvp-2.0.4.js
dist/rsvp-2.0.4.js
+11
-1
dist/rsvp-2.0.4.min.js
dist/rsvp-2.0.4.min.js
+1
-1
lib/rsvp/resolve.js
lib/rsvp/resolve.js
+11
-1
test/tests/extension_test.js
test/tests/extension_test.js
+21
-3
No files found.
dist/commonjs/rsvp/resolve.js
View file @
fdaaddad
...
...
@@ -3,7 +3,17 @@ var Promise = require("./promise").Promise;
function
resolve
(
thenable
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
thenable
);
if
(
typeof
thenable
===
"
object
"
&&
thenable
!==
null
)
{
var
then
=
thenable
.
then
;
if
((
then
!==
undefined
)
&&
(
typeof
then
===
"
function
"
))
{
return
then
.
apply
(
thenable
,
[
resolve
,
reject
]);
}
}
return
resolve
(
thenable
);
},
function
()
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
thenable
.
cancel
();
}
});
}
...
...
dist/rsvp-2.0.4.amd.js
View file @
fdaaddad
...
...
@@ -828,7 +828,17 @@ define("rsvp/resolve",
function
resolve
(
thenable
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
thenable
);
if
(
typeof
thenable
===
"
object
"
&&
thenable
!==
null
)
{
var
then
=
thenable
.
then
;
if
((
then
!==
undefined
)
&&
(
typeof
then
===
"
function
"
))
{
return
then
.
apply
(
thenable
,
[
resolve
,
reject
]);
}
}
return
resolve
(
thenable
);
},
function
()
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
thenable
.
cancel
();
}
});
}
...
...
dist/rsvp-2.0.4.js
View file @
fdaaddad
...
...
@@ -865,7 +865,17 @@ define("rsvp/resolve",
function
resolve
(
thenable
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
thenable
);
if
(
typeof
thenable
===
"
object
"
&&
thenable
!==
null
)
{
var
then
=
thenable
.
then
;
if
((
then
!==
undefined
)
&&
(
typeof
then
===
"
function
"
))
{
return
then
.
apply
(
thenable
,
[
resolve
,
reject
]);
}
}
return
resolve
(
thenable
);
},
function
()
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
thenable
.
cancel
();
}
});
}
...
...
dist/rsvp-2.0.4.min.js
View file @
fdaaddad
This diff is collapsed.
Click to expand it.
lib/rsvp/resolve.js
View file @
fdaaddad
...
...
@@ -2,7 +2,17 @@ import { Promise } from "./promise";
function
resolve
(
thenable
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
resolve
(
thenable
);
if
(
typeof
thenable
===
"
object
"
&&
thenable
!==
null
)
{
var
then
=
thenable
.
then
;
if
((
then
!==
undefined
)
&&
(
typeof
then
===
"
function
"
))
{
return
then
.
apply
(
thenable
,
[
resolve
,
reject
]);
}
}
return
resolve
(
thenable
);
},
function
()
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
thenable
.
cancel
();
}
});
}
...
...
test/tests/extension_test.js
View file @
fdaaddad
...
...
@@ -1335,9 +1335,10 @@ describe("RSVP extensions", function() {
wrapped
=
RSVP
.
resolve
(
thenable
);
assert
(
accessCount
===
1
);
done
();
setTimeout
(
function
()
{
assert
(
accessCount
===
1
);
done
();
},
20
);
});
specify
(
"
2.2 If retrieving the property x.then results in a thrown exception e, reject promise with e as the reason.
"
,
function
(
done
){
...
...
@@ -1532,6 +1533,23 @@ describe("RSVP extensions", function() {
assert
(
callCount
===
0
,
'
expected async, was sync
'
);
});
});
describe
(
"
4. If x is a promise,
"
,
function
(){
specify
(
"
cancel will also cancel x.
"
,
function
(
done
){
var
thenable
,
wrapped
;
thenable
=
RSVP
.
delay
();
wrapped
=
RSVP
.
resolve
(
thenable
);
thenable
.
fail
(
function
(
error
){
assert
(
error
instanceof
RSVP
.
CancellationError
,
'
expected CancellationError
'
);
done
();
});
wrapped
.
cancel
();
});
});
});
});
...
...
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