Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove queue specific options #304

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/backburner/deferred-action-queues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class DeferredActionQueues {
this.queueNames = queueNames;

queueNames.reduce(function(queues, queueName) {
queues[queueName] = new Queue(queueName, options[queueName], options);
queues[queueName] = new Queue(queueName, options);
return queues;
}, this.queues);
}
Expand Down
17 changes: 3 additions & 14 deletions lib/backburner/queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,15 @@ const QUEUE_ITEM_LENGTH = 4;

export default class Queue {
private name: string;
private globalOptions: any;
private options: any;
private _queueBeingFlushed: any[] = [];
private targetQueues = new Map();
private index = 0;
private _queue: any[] = [];

constructor(name: string, options: any = {}, globalOptions: any = {}) {
constructor(name: string, options: any = {}) {
this.name = name;
this.options = options;
this.globalOptions = globalOptions;
}

public stackFor(index) {
Expand All @@ -38,7 +36,6 @@ export default class Queue {
}

public flush(sync?: Boolean) {
let { before, after } = this.options;
let target;
let method;
let args;
Expand All @@ -50,14 +47,10 @@ export default class Queue {
this._queue = [];
}

if (before !== undefined) {
before();
}

let invoke;
let queueItems = this._queueBeingFlushed;
if (queueItems.length > 0) {
let onError = getOnError(this.globalOptions);
let onError = getOnError(this.options);
invoke = onError ? this.invokeWithOnError : this.invoke;

for (let i = this.index; i < queueItems.length; i += QUEUE_ITEM_LENGTH) {
Expand Down Expand Up @@ -88,16 +81,12 @@ export default class Queue {
}

if (this.index !== this._queueBeingFlushed.length &&
this.globalOptions.mustYield && this.globalOptions.mustYield()) {
this.options.mustYield && this.options.mustYield()) {
return QUEUE_STATE.Pause;
}
}
}

if (after !== undefined) {
after();
}

this._queueBeingFlushed.length = 0;
this.index = 0;
if (sync !== false && this._queue.length > 0) {
Expand Down