I have some setup I want during a constructor, but it seems that is not allowed
Which means I can\'t use:
How else should I do this?
<
A constructor must return an instance of the class it 'constructs'. Therefore, it's not possible to return Promise<...>
and await for it.
You can:
Make your public setup async
.
Do not call it from the constructor.
Call it whenever you want to 'finalize' object construction.
async function run()
{
let topic;
debug("new TopicsModel");
try
{
topic = new TopicsModel();
await topic.setup();
}
catch (err)
{
debug("err", err);
}
}