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
Romain Courteaud
rsvp.js
Commits
8dcbf352
Commit
8dcbf352
authored
Apr 19, 2019
by
Romain Courteaud
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Experiment other implementations.
Not working with listbox
parent
974b8596
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
46 deletions
+73
-46
lib/rsvp/queue.js
lib/rsvp/queue.js
+73
-46
No files found.
lib/rsvp/queue.js
View file @
8dcbf352
...
@@ -17,66 +17,93 @@ var Queue = function() {
...
@@ -17,66 +17,93 @@ var Queue = function() {
return
new
Queue
();
return
new
Queue
();
}
}
var
promise_stack
=
[],
var
function_stack
=
[],
// handleQueue
resolveQueue
,
detect_end_index
=
1
;
rejectQueue
,
queue
=
this
,
current_promise
=
null
,
handleDone
,
handleReject
,
next_function
;
Promise
.
call
(
this
,
function
(
resolveQueue
,
rejectQueue
)
{
handleDone
=
function
(
result
)
{
var
detectQueueSuccess
,
if
(
queue
.
isRejected
)
{
detectQueueError
;
return
;
}
function
handleQueue
()
{
if
(
function_stack
.
length
>
0
)
{
if
(
promise_stack
.
length
===
detect_end_index
)
{
next_function
=
function_stack
.
shift
();
return
true
;
// Remove fail handler
function_stack
.
shift
();
if
(
next_function
===
undefined
)
{
return
handleDone
(
result
);
}
}
promise_stack
.
splice
(
0
,
detect_end_index
);
try
{
current_promise
=
next_function
.
call
(
null
,
result
);
promise_stack
.
push
(
}
catch
(
e
)
{
promise_stack
[
promise_stack
.
length
-
1
].
then
(
detectQueueSuccess
,
return
handleReject
(
e
);
detectQueueError
)
}
);
if
((
current_promise
!==
undefined
)
&&
detect_end_index
=
promise_stack
.
length
;
(
typeof
current_promise
.
then
===
"
function
"
))
{
return
false
;
current_promise
.
then
(
handleDone
,
handleReject
);
}
else
{
handleDone
(
current_promise
);
}
return
;
}
}
resolveQueue
(
result
);
};
detectQueueSuccess
=
function
(
fulfillmentValue
)
{
handleReject
=
function
(
error
)
{
if
(
handleQueue
())
{
if
(
queue
.
isRejected
)
{
return
resolveQueue
(
fulfillmentValue
);
return
;
}
if
(
function_stack
.
length
>
0
)
{
// Remove done handler
function_stack
.
shift
();
next_function
=
function_stack
.
shift
();
if
(
next_function
===
undefined
)
{
return
handleReject
(
error
);
}
}
return
fulfillmentValue
;
try
{
};
current_promise
=
next_function
.
call
(
null
,
error
);
}
catch
(
e
)
{
detectQueueError
=
function
(
rejectedReason
)
{
return
handleReject
(
e
);
if
(
handleQueue
())
{
return
rejectQueue
(
rejectedReason
);
}
}
throw
rejectedReason
;
if
((
current_promise
!==
undefined
)
&&
};
(
typeof
current_promise
.
then
===
"
function
"
))
{
current_promise
.
then
(
handleDone
,
handleReject
);
// Resolve by default
}
else
{
promise_stack
.
push
(
handleDone
(
current_promise
);
resolve
().
then
(
detectQueueSuccess
)
}
);
return
;
},
function
()
{
// Cancel all created promises
var
i
;
for
(
i
=
0
;
i
<
promise_stack
.
length
;
i
+=
1
)
{
promise_stack
[
i
].
cancel
();
}
}
rejectQueue
(
error
);
}
)
;
};
this
.
push
=
function
(
done
,
fail
)
{
this
.
push
=
function
(
done
,
fail
)
{
if
(
this
.
isFulfilled
||
this
.
isRejected
)
{
if
(
this
.
isFulfilled
||
this
.
isRejected
||
this
.
isCancelled
)
{
throw
new
ResolvedQueueError
();
throw
new
ResolvedQueueError
();
}
}
promise_stack
.
push
(
function_stack
.
push
(
done
,
fail
);
promise_stack
[
promise_stack
.
length
-
1
].
then
(
done
,
fail
)
);
return
this
;
return
this
;
};
};
Promise
.
call
(
this
,
function
(
done
,
fail
)
{
resolveQueue
=
done
;
rejectQueue
=
fail
;
// Resolve by default
function_stack
.
push
(
resolve
,
undefined
);
handleDone
();
},
function
()
{
// Skip not executed .push
function_stack
=
[];
// Cancel currently running promise
if
((
current_promise
!==
undefined
)
&&
(
typeof
current_promise
.
cancel
===
"
function
"
))
{
current_promise
.
cancel
();
}
});
return
this
;
return
this
;
};
};
...
...
Romain Courteaud
@romain
mentioned in commit
9b922f24
·
Feb 25, 2020
mentioned in commit
9b922f24
mentioned in commit 9b922f241651d957fb358158faceb8f9e8473d96
Toggle commit list
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