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
4118cd40
Commit
4118cd40
authored
Sep 27, 2013
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cancel `all` or `any` with non cancellable thenables
parent
34a4233b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
70 additions
and
1 deletion
+70
-1
lib/rsvp/all.js
lib/rsvp/all.js
+2
-1
test/tests/extension_test.js
test/tests/extension_test.js
+68
-0
No files found.
lib/rsvp/all.js
View file @
4118cd40
...
...
@@ -12,7 +12,8 @@ function promiseAtLeast(expected_count, promises) {
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
promise
=
promises
[
i
];
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
)
{
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
&&
typeof
promise
.
cancel
===
'
function
'
)
{
promise
.
cancel
();
}
}
...
...
test/tests/extension_test.js
View file @
4118cd40
...
...
@@ -782,6 +782,40 @@ describe("RSVP extensions", function() {
},
20
);
});
specify
(
'
cancel with non cancellable thenables
'
,
function
(
done
)
{
var
firstResolver
,
secondResolver
;
var
first
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
firstResolver
=
{
resolve
:
resolve
,
reject
:
reject
};
});
var
second
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
secondResolver
=
{
resolve
:
resolve
,
reject
:
reject
};
});
setTimeout
(
function
()
{
firstResolver
.
reject
({});
},
0
);
setTimeout
(
function
()
{
secondResolver
.
resolve
(
true
);
},
5000
);
var
all_promise
=
RSVP
.
all
([{
"
then
"
:
function
()
{
return
;
}},
first
,
second
]);
all_promise
.
cancel
();
setTimeout
(
function
()
{
assert
(
first
.
isRejected
);
assert
(
first
.
rejectedReason
instanceof
RSVP
.
CancellationError
);
assert
(
second
.
isRejected
);
assert
(
second
.
rejectedReason
instanceof
RSVP
.
CancellationError
);
done
();
},
20
);
});
specify
(
'
notifies promises progress
'
,
function
(
done
)
{
var
firstResolver
,
secondResolver
,
count
=
0
,
expected
=
{};
...
...
@@ -992,6 +1026,40 @@ describe("RSVP extensions", function() {
},
20
);
});
specify
(
'
cancel with non cancellable thenables
'
,
function
(
done
)
{
var
firstResolver
,
secondResolver
;
var
first
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
firstResolver
=
{
resolve
:
resolve
,
reject
:
reject
};
});
var
second
=
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
secondResolver
=
{
resolve
:
resolve
,
reject
:
reject
};
});
setTimeout
(
function
()
{
firstResolver
.
reject
({});
},
0
);
setTimeout
(
function
()
{
secondResolver
.
resolve
(
true
);
},
5000
);
var
all_promise
=
RSVP
.
any
([{
"
then
"
:
function
()
{
return
;
}},
first
,
second
]);
all_promise
.
cancel
();
setTimeout
(
function
()
{
assert
(
first
.
isRejected
);
assert
(
first
.
rejectedReason
instanceof
RSVP
.
CancellationError
);
assert
(
second
.
isRejected
);
assert
(
second
.
rejectedReason
instanceof
RSVP
.
CancellationError
);
done
();
},
20
);
});
specify
(
'
notifies promises progress
'
,
function
(
done
)
{
var
firstResolver
,
secondResolver
,
count
=
0
,
expected
=
{};
...
...
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