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
08ff89d4
Commit
08ff89d4
authored
Dec 12, 2021
by
Gabriel Monnerat
Committed by
Romain Courteaud
Dec 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cancel: propagate message
parent
e18484cb
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
31 deletions
+111
-31
lib/rsvp/all.js
lib/rsvp/all.js
+2
-2
lib/rsvp/hash.js
lib/rsvp/hash.js
+2
-2
lib/rsvp/promise.js
lib/rsvp/promise.js
+3
-3
lib/rsvp/queue.js
lib/rsvp/queue.js
+4
-4
lib/rsvp/resolve.js
lib/rsvp/resolve.js
+2
-2
test/tests/extension_test.js
test/tests/extension_test.js
+98
-18
No files found.
lib/rsvp/all.js
View file @
08ff89d4
...
@@ -7,14 +7,14 @@ function promiseAtLeast(expected_count, promises) {
...
@@ -7,14 +7,14 @@ function promiseAtLeast(expected_count, promises) {
throw
new
TypeError
(
'
You must pass an array to all.
'
);
throw
new
TypeError
(
'
You must pass an array to all.
'
);
}
}
function
canceller
()
{
function
canceller
(
msg
)
{
var
promise
;
var
promise
;
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
promise
=
promises
[
i
];
promise
=
promises
[
i
];
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
&&
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
&&
typeof
promise
.
cancel
===
'
function
'
)
{
typeof
promise
.
cancel
===
'
function
'
)
{
promise
.
cancel
();
promise
.
cancel
(
msg
);
}
}
}
}
}
}
...
...
lib/rsvp/hash.js
View file @
08ff89d4
...
@@ -12,7 +12,7 @@ function size(object) {
...
@@ -12,7 +12,7 @@ function size(object) {
function
hash
(
promises
)
{
function
hash
(
promises
)
{
function
canceller
()
{
function
canceller
(
msg
)
{
var
promise
,
var
promise
,
key
;
key
;
for
(
key
in
promises
)
{
for
(
key
in
promises
)
{
...
@@ -21,7 +21,7 @@ function hash(promises) {
...
@@ -21,7 +21,7 @@ function hash(promises) {
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
&&
if
(
promise
&&
typeof
promise
.
then
===
'
function
'
&&
typeof
promise
.
cancel
===
'
function
'
)
{
typeof
promise
.
cancel
===
'
function
'
)
{
promise
.
cancel
();
promise
.
cancel
(
msg
);
}
}
}
}
}
}
...
...
lib/rsvp/promise.js
View file @
08ff89d4
...
@@ -45,21 +45,21 @@ var Promise = function(resolver, canceller) {
...
@@ -45,21 +45,21 @@ var Promise = function(resolver, canceller) {
this
.
on
(
'
error
'
,
onerror
);
this
.
on
(
'
error
'
,
onerror
);
this
.
cancel
=
function
()
{
this
.
cancel
=
function
(
msg
)
{
// For now, simply reject the promise and does not propagate the cancel
// For now, simply reject the promise and does not propagate the cancel
// to parent or children
// to parent or children
if
(
resolved
)
{
return
;
}
if
(
resolved
)
{
return
;
}
promise
.
isCancelled
=
true
;
promise
.
isCancelled
=
true
;
if
(
canceller
!==
undefined
)
{
if
(
canceller
!==
undefined
)
{
try
{
try
{
canceller
();
canceller
(
msg
);
}
catch
(
e
)
{
}
catch
(
e
)
{
rejectPromise
(
e
);
rejectPromise
(
e
);
return
;
return
;
}
}
}
}
// Trigger cancel?
// Trigger cancel?
rejectPromise
(
new
CancellationError
());
rejectPromise
(
new
CancellationError
(
msg
));
};
};
try
{
try
{
...
...
lib/rsvp/queue.js
View file @
08ff89d4
...
@@ -24,9 +24,9 @@ var Queue = function(thenable) {
...
@@ -24,9 +24,9 @@ var Queue = function(thenable) {
return
new
Queue
(
thenable
);
return
new
Queue
(
thenable
);
}
}
function
canceller
()
{
function
canceller
(
msg
)
{
for
(
var
i
=
promise_list
.
length
;
i
>
0
;
i
--
)
{
for
(
var
i
=
promise_list
.
length
;
i
>
0
;
i
--
)
{
promise_list
[
i
-
1
].
cancel
();
promise_list
[
i
-
1
].
cancel
(
msg
);
}
}
}
}
...
@@ -69,10 +69,10 @@ var Queue = function(thenable) {
...
@@ -69,10 +69,10 @@ var Queue = function(thenable) {
checkPromise
(
resolve
(
thenable
));
checkPromise
(
resolve
(
thenable
));
queue
.
cancel
=
function
()
{
queue
.
cancel
=
function
(
msg
)
{
if
(
resolved
)
{
return
;}
if
(
resolved
)
{
return
;}
resolved
=
true
;
resolved
=
true
;
promise
.
cancel
();
promise
.
cancel
(
msg
);
promise
.
fail
(
function
(
rejectedReason
)
{
promise
.
fail
(
function
(
rejectedReason
)
{
queue
.
isRejected
=
true
;
queue
.
isRejected
=
true
;
queue
.
rejectedReason
=
rejectedReason
;
queue
.
rejectedReason
=
rejectedReason
;
...
...
lib/rsvp/resolve.js
View file @
08ff89d4
...
@@ -9,9 +9,9 @@ function resolve(thenable) {
...
@@ -9,9 +9,9 @@ function resolve(thenable) {
}
}
}
}
return
resolve
(
thenable
);
return
resolve
(
thenable
);
},
function
()
{
},
function
(
msg
)
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
if
((
thenable
!==
undefined
)
&&
(
thenable
.
cancel
!==
undefined
))
{
thenable
.
cancel
();
thenable
.
cancel
(
msg
);
}
}
});
});
}
}
...
...
test/tests/extension_test.js
View file @
08ff89d4
This diff is collapsed.
Click to expand it.
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