create-discord-bot icon indicating copy to clipboard operation
create-discord-bot copied to clipboard

Global Dependencies

Open shadowtime2000 opened this issue 5 years ago • 1 comments

Currently there is no way to have global dependencies that are only initialized once. I think we should have a deps.js file which has some global dependencies. It could be like this:

const dbORM = require("db-orm");

const connection = dbOrm("my-connection");

module.exports = {
  connection
};

So then only one connection is created which is reused through out the different widgets.

shadowtime2000 avatar Nov 21 '20 22:11 shadowtime2000

We would still have to figure out how exactly using those dependencies should work. How about, if the event handler is an object, use deps as a list of dependencies that match to names of keys in deps.js and create an object from that, and inject that into the creator value of that object, and use the output as the event handler. If it is a function, just use it. We would probably have to do some forwarding of the dependencies to the command handlers in the command widget.

shadowtime2000 avatar Nov 22 '20 01:11 shadowtime2000