rework routing
This commit is contained in:
parent
636cdf1b8f
commit
e37c07adb4
@ -1,13 +1,19 @@
|
|||||||
|
/* Simple asynchronous queue.
|
||||||
|
To make `get` blocking, we create a new promise and store its `resolve` function in `resolvers`.
|
||||||
|
The next time an item is added to the queue, it will be resolved.
|
||||||
|
*/
|
||||||
|
|
||||||
export default function() {
|
export default function() {
|
||||||
return {
|
return {
|
||||||
items: [],
|
items: [],
|
||||||
|
|
||||||
resolvers: []
|
resolvers: [],
|
||||||
|
|
||||||
put(item) {
|
put(item) {
|
||||||
this.items.push(item);
|
this.items.push(item);
|
||||||
if (resolvers.length > 0) {
|
if (this.resolvers.length > 0) {
|
||||||
resolvers.shift().resolve();
|
let resolver = this.resolvers.shift();
|
||||||
|
resolver();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user