Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Architecure) Parameters as singleton #49

Closed
Blondwolf opened this issue Feb 6, 2024 · 2 comments
Closed

(Architecure) Parameters as singleton #49

Blondwolf opened this issue Feb 6, 2024 · 2 comments

Comments

@Blondwolf
Copy link

Blondwolf commented Feb 6, 2024

This ticket is to discuss about wether or not it would be a good idea to create a singleton to store global settings as mentioned here

@Blondwolf
Copy link
Author

Blondwolf commented Feb 6, 2024

Not sure about this personally. I dont find much documentation about Obsidian plugins dev.

It feels like this.settings.isDebug for example can be accessible directly from the Plugin class. So the Plugin already has this settings. You could just send those setting in a class which is already created src/Model/Settings.js.

If you want to simplify the parameters, you can just pass this.settings from the main to other classes you need for treatment.

Then instead of

this.taskFinder = new TaskFinder(this.app.vault, this.settings.howToParseInternalLinks, this.settings.ignoreCompletedTasks, this.settings.ignoreOldTasks, this.settings.oldTaskInDays, this.settings.isIncludeTodos);

You can do

this.taskFinder = new TaskFinder(this.app.vault, this.settings);

And then process to get them back in the class the same way you would do with a singleton

this.howToParseInternalLinks = settings.howToParseInternalLinks;
this.ignoreCompletedTasks = settings.ignoreCompletedTasks;

@andrewbrereton
Copy link
Owner

Resolved in #51 and released in 1.15.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants