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

fix #565: setup data after config loaded #572

Open
wants to merge 2 commits into
base: harpoon2
Choose a base branch
from

Conversation

rndev-io
Copy link

No description provided.

@akyrey
Copy link

akyrey commented Apr 11, 2024

@rusnasonov thank you for the PR.

What about leaving the data initialization and sync_on_change function also inside Harpoon::new() and edit Harpoon::setup() like you did but with sync_on_change(self) moved right before the final return?

@rndev-io
Copy link
Author

What about leaving the data initialization and sync_on_change function also inside Harpoon::new()

It's creates additional empty data file with default key, which will never be used. If it's ok - why not.

but with sync_on_change(self) moved right before the final return?

Ok

@maxrzaw
Copy link

maxrzaw commented May 21, 2024

This also fixes #577

@@ -146,6 +146,7 @@ function Harpoon.setup(self, partial_config)

---@diagnostic disable-next-line: param-type-mismatch
self.config = Config.merge_config(partial_config, self.config)
self.data = Data.Data:new(self.config)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found this MR just before creating my pull request :) Looks like it takes time to get it merged.
One suggestion from me would be to check at least for the partial_config to be non-empty. Otherwise we don't need to reload data and calling sync_on_change (e.g. if it was just harpoon.setup({})).

Suggested change
self.data = Data.Data:new(self.config)
if partial_config then
self.data = Data.Data:new(self.config)
end

(and the same if before calling sync_on_change).

benelan added a commit to benelan/harpoon that referenced this pull request Feb 17, 2025
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

Successfully merging this pull request may close these issues.

4 participants