How to fix Replacing an existing Haven instance. Are you sure this behaviour is intended?
#142
Open
Description
Hi,
First of all, a big thank you for creating this package. It's really helpful.
I'd like to know if it would be possible for you to instead of console.warn("Replacing an existing Haven instance. Are you sure this behaviour is intended?");
if you could simply return the existing instance.
create would be like this
public static create(options: Partial<HavenOptions>): Haven {
if (Haven.instance) {
return Haven.instance
} else {
Haven.instance = new Haven(options);
Haven.instance.init();
return Haven.instance;
}
}
If we have already an instance then there's no point in creating a new one right?
In my code I'm doing
const havenInstance = Haven.getInstance()
if (!havenInstance) {
Haven.create(options)
}
But now I'm getting a console error because getInstance()
has this console.error("No Haven instance found. Make sure to create a Haven instance before attempting to access it.")
Thank you
Metadata
Assignees
Labels
No labels