-
Notifications
You must be signed in to change notification settings - Fork 80
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
Support for synchronous operations #104
Comments
Hi @philippefutureboy, thanks for the nice words! I'm definitely open to a PR that adds the sync functions. Do you think there is a way we can provide both without much duplication in the internal implementation? |
Nice! I'll give it a look next week to see how I can contribute. After a quick readthrough, my suggestion would be to include
I'm sure this could reduce the duplication of code :) |
~ weeks later ~ So I have more time on hand now, I can contribute. I was thinking to rehaul the entire library to use fs-extra and Promises. Would that be something you'd be interested in? |
I'd prefer keeping the list of dependencies to a minimum. There is an existing PR for adding promise support: #105.
Lets give that a shot, and see how it goes, as it sounds very cool :) Regarding |
Wait, so do you want
What do you think? |
We're not dealing with objects that require deep merging, right? (the ones in the example above are one level, so Regarding |
True! Sorry, I realized I hadn't communicated the changes that I had thought about since we last discussed. Essentially what I realized is that a lot of the logic in your package can be replaced with What do you think? |
@philippefutureboy I see what you mean now. Yeah, lets give it a shot, and see how the result looks like. If the amount of code is reduced, then that's a big win, and will make it easier to then refactor the project to offer both sync and async versions of the functions. |
@jviotti Wonderful! I'll give it a look this weekend |
@jviotti I haven't forgotten this. I'm simply overwhelmed with work. I'll definitely get back to this at some point cause I want to see this through. I also had an idea that I implemented on my side and that works wonders – I wrapped the storage module with an EventEmitter pattern, which grants me the ability to subscribe services to changes in state. This, in turn, allows to get state always synchronously (exception being the initialization). This is because the get state function on my wrapper only retrieve cached state, and updates the cached state on set. Anywho, we'll discuss more in details when I actually get some time 😅 Have a wonderful day, Cheers, Philippe |
Hi!
First of all, thank you for the good work, works like a charm! 🚀
I would like to know if it would be possible to provide a sync implementation of the API. Indeed, in cases where the JSON storage data is used to instantiate modules, having to wrap the instantiation with a Promise/callback is less than optimal. For instance, in my case I am receiving database connection configuration from the user, and I store it locally. I can then use this to instantiate my database by default on the subsequent boots of the app.
This would be a really useful :D
Have a wonderful day,
Cheers,
Philippe
The text was updated successfully, but these errors were encountered: