Skip to content

Commit

Permalink
Remove add function according to code review
Browse files Browse the repository at this point in the history
Adept setter to be a two for one function
  • Loading branch information
Sven E. Stolk committed Oct 14, 2019
1 parent c8a800b commit d02aadc
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ const Queue = require('bull');
const someQueue = new Queue();
const someOtherQueue = new Queue();

const { addQueue, setQueues } = require('bull-board')
const { setQueues } = require('bull-board')

addQueue(someQueue).addQueue(someOtherQueue)
setQueues(someQueue)

// OR

Expand Down
5 changes: 3 additions & 2 deletions example.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { createQueues, addQueue, setQueues, UI } = require('./')
const { createQueues, setQueues, UI } = require('./')
const app = require('express')()

const sleep = t => new Promise(resolve => setTimeout(resolve, t * 1000))
Expand All @@ -13,8 +13,9 @@ const redisOptions = {
}

const run = () => {
addQueue(/* Already defined (bull) queue */);
setQueues([/* Already defined (bull) queues */]);
// Or a single bull queue
setQueues(/* Already defined bull queue */);

const queues = createQueues(redisOptions)

Expand Down
15 changes: 8 additions & 7 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ function UI() {

module.exports = {
UI: UI(),
setQueues: (queues) => {
queues.forEach((item) => {
this.addQueue(item.queue);
setQueues: (bullQueues) => {
if (!Array.isArray(bullQueues)) {
bullQueues = [bullQueues];
}

bullQueues.forEach((item) => {
queues[item.name] = item;
})
},
addQueue: (queue) => {
queues[queue.name] = queue

return this;
return queues
},
createQueues: redis => {
return {
Expand Down

0 comments on commit d02aadc

Please sign in to comment.