rework routing
This commit is contained in:
1 parent
636cdf1b8f
commit
e37c07adb4
1 file changed
+9
-3
+9
-3
@@ -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() {
|
||||
return {
|
||||
items: [],
|
||||
|
||||
resolvers: []
|
||||
resolvers: [],
|
||||
|
||||
put(item) {
|
||||
this.items.push(item);
|
||||
if (resolvers.length > 0) {
|
||||
resolvers.shift().resolve();
|
||||
if (this.resolvers.length > 0) {
|
||||
let resolver = this.resolvers.shift();
|
||||
resolver();
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user