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
58953a31
Commit
58953a31
authored
Feb 06, 2014
by
Tristan Cavelier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Queue notifications are now enabled
parent
41eba17a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
46 additions
and
5 deletions
+46
-5
lib/rsvp/queue.js
lib/rsvp/queue.js
+13
-5
test/tests/extension_test.js
test/tests/extension_test.js
+33
-0
No files found.
lib/rsvp/queue.js
View file @
58953a31
...
...
@@ -18,6 +18,7 @@ var Queue = function() {
promise
,
fulfill
,
reject
,
notify
,
resolved
;
if
(
!
(
this
instanceof
Queue
))
{
...
...
@@ -30,7 +31,7 @@ var Queue = function() {
}
}
promise
=
new
Promise
(
function
(
done
,
fail
)
{
promise
=
new
Promise
(
function
(
done
,
fail
,
progress
)
{
fulfill
=
function
(
fulfillmentValue
)
{
if
(
resolved
)
{
return
;}
queue
.
isFulfilled
=
true
;
...
...
@@ -45,6 +46,7 @@ var Queue = function() {
resolved
=
true
;
return
fail
(
rejectedReason
);
};
notify
=
progress
;
},
canceller
);
promise_list
.
push
(
delay
());
...
...
@@ -68,7 +70,7 @@ var Queue = function() {
return
promise
.
then
.
apply
(
promise
,
arguments
);
};
queue
.
push
=
function
(
done
,
fail
)
{
queue
.
push
=
function
(
done
,
fail
,
progress
)
{
var
last_promise
=
promise_list
[
promise_list
.
length
-
1
],
next_promise
;
...
...
@@ -76,11 +78,11 @@ var Queue = function() {
throw
new
ResolvedQueueError
();
}
next_promise
=
last_promise
.
then
(
done
,
fail
);
next_promise
=
last_promise
.
then
(
done
,
fail
,
progress
);
promise_list
.
push
(
next_promise
);
// Handle pop
promise_list
.
push
(
next_promise
.
then
(
function
(
fulfillmentValue
)
{
last_promise
=
next_promise
.
then
(
function
(
fulfillmentValue
)
{
promise_list
.
splice
(
0
,
2
);
if
(
promise_list
.
length
===
0
)
{
fulfill
(
fulfillmentValue
);
...
...
@@ -94,7 +96,13 @@ var Queue = function() {
}
else
{
throw
rejectedReason
;
}
}));
},
function
(
notificationValue
)
{
if
(
promise_list
[
promise_list
.
length
-
1
]
===
last_promise
)
{
notify
(
notificationValue
);
}
return
notificationValue
;
});
promise_list
.
push
(
last_promise
);
return
this
;
};
...
...
test/tests/extension_test.js
View file @
58953a31
...
...
@@ -2404,5 +2404,38 @@ describe("`RSVP.Queue`", function () {
done
();
},
20
);
});
it
(
"
notify should be propagated until `then`
"
,
function
(
done
)
{
var
queue
=
new
RSVP
.
Queue
(),
i
=
0
,
responses
=
[];
queue
.
push
(
function
()
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
,
notify
)
{
notify
(
"
hello
"
);
});
});
queue
.
push
(
null
,
null
,
function
(
notification
)
{
responses
.
push
(
1
);
responses
.
push
(
notification
);
return
notification
;
});
queue
.
push
(
function
()
{
return
;
});
queue
.
then
(
null
,
null
,
function
(
notification
)
{
responses
.
push
(
2
);
responses
.
push
(
notification
);
});
setTimeout
(
function
()
{
assert
.
equal
(
responses
[
0
],
1
);
assert
.
equal
(
responses
[
1
],
"
hello
"
,
"
Notification
"
);
assert
.
equal
(
responses
[
2
],
2
);
assert
.
equal
(
responses
[
3
],
"
hello
"
,
"
Notification
"
);
done
();
},
50
);
});
});
});
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