-
Notifications
You must be signed in to change notification settings - Fork 29
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
Multiple instances conflict, but only a little #199
Comments
Yep, this is an issue for sure, would require a bit of a refactor |
By design the electron-preferences is created to be used as a single instance. Can I ask why you have the architecture of both If possible, I would go for the single window design which should fix your issue, and probably makes your application more simple and elegant? |
We went back and forth on whether they are two things or one. I can give you examples of applications that make each choice. For us, there seemed to be a clear difference. Setting a proxy, is not a "preference" in any sense. If you don't set the proxy server when you need it, you can't connect. On the other hand, if you don't like confirmation dialogs, that is just a matter of taste. How does this logical distinction play out? Well, here's an example. We are planning on having a way of sharing settings, so that if a team all needs a certain setting (e.g. the whole team needs to use a certain proxy server), they can share it. But, clearly, sharing preferences is silly. The distinction also plays out in documentation, of course. Could we use a single "settings/preferences" page with different tabs, where some tabs are "settings-like" and others are "preferences-like"? Of course, we could. But I'm comfortable that we made the right choice in doing it this way. We have kludged around the issue for now by writing our own destroy(). As I mentioned in another issue, I hope to be able to provide a PR, if the fates allow. |
I actually had a use-case for two separate windows as well a couple years ago and ended up creating a custom dialog window. This would definitely be beneficial. |
Describe the bug
In our project, we have multiple preferences-like pages. In particular, we have a "Settings" page and a "Preferences" page. Obviously, settings refers to things like "proxy address" which is hardly a "preference" if you can't possibly work without it. "Preferences", on the other hand, is for things like use of confirmation dialogs.
One can't have multiple instances of electron-preferences since the ipcMain.on() registrations conflict. We have worked around this in our code, by doing ipcMain.removeAllListeners() liberally. But a better approach would be to take down the listeners upon "close" or to support a "destroy" API.
I lean towards the "destroy" approach, as it allows some control for the user of the API. If you have only one, there may be no reason to keep creating and destroying things.
Also, the destroy API can do things like getting rid of the prefsWindow object and other wasteful things.
To Reproduce
Expected behavior
It would be expected that each instance would operate independently.
The text was updated successfully, but these errors were encountered: