How do I retrieve a queue created in another file to add a job? (Without polluting global namespace) #1959
Unanswered
stephanoparaskeva
asked this question in
Q&A
Replies: 2 comments 3 replies
-
I am not sure what your issue is, you just use the same name of the queue that you want to refer to. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Is the issue that instantiating a queue object has side effects (like creating connections to Redis) so you don't want that to happen when the module is imported? The way I've dealt with that in the past is with something like this: let queue;
module.exports = () => {
if (!queue) { queue = new Queue(); }
return queue;
}; Then you're not polluting the global namespace, just your module-local one. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Incorrect:
Desired
Beta Was this translation helpful? Give feedback.
All reactions