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() {
|
||||
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();
|
||||
}
|
||||
},
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user