Comments (9)
I don't have an opinion but I love the breakdown of pros and cons. Looking forward to seeing what others think.
from desktop.
Maybe storing global state in localStorage
? Which is shared in all renderer processes.
from desktop.
@zcbenz Good point! I'd be concerned that if N renderers own the state, then it's equivalent to no one owning the state. For example, if we change something and need to broadcast it out to all the renderers, or coordinate some change, we still need something central doing that.
from desktop.
I had some trouble using localStorage because it's not persisted to disk until the app exits cleanly. So if the app crashes or you're working in development and ctrlc out, your state changes are lost.
https://github.com/sindresorhus/electron-config looks interesting. I haven't used it yet.
from desktop.
So will desktop have multiple windows, like one per repository perhaps?
If that is the case, then is the state we are talking here mostly preferences that apply to all windows, like user preferences and a few global app-wide events (like auto update)?
from desktop.
So will desktop have multiple windows, like one per repository perhaps?
Right.
If that is the case, then is the state we are talking here mostly preferences that apply to all windows, like user preferences and a few global app-wide events (like auto update)?
Right, or the lists of logged in users, tracked repositories, etc.
from desktop.
Right, or the lists of logged in users, tracked repositories, etc.
I think the background process (3) approach might work best for this.
One invisible window syncs and dispatches app-wide state changes and can easily be shown when debugging/profiling is needed.
IPC would (I think?) be two-step. Renderer -> main process -> background process.
Yeah, the messages would have go to through the the main process but you could do it all from the background process window.
A window can use the remote module to communicate with other windows "directly", messages still go through the main process but the code is initiated from the background window process making it easier to debug.
backgroundWindow.js
const {getCurrentWindow, BrowserWindow} = require('electron').remote
console.log(`Starting refresh of repositories at ${Date()}`)
refreshRepos().then((repos) => {
// Assign to global for debugging
window.latestRepos = repos
console.log(`Repos refreshed at ${Date()}`)
// Notify all windows of new repo state
BrowserWindow.getAllWindows().forEach((window) => {
// Send IPC event directly to renderer process remotely
window.webContents.send('repos-refreshed', repos)
})
}).catch((error) => {
console.error(`Repos refresh failed at ${Date()}`)
console.error(error)
if (process.env.NODE_ENV === 'development') {
// Show background window on errors when developing
getCurrentWindow().show()
getCurrentWindow().openDevTools()
}
})
window1.js, window2.js, ...
const {ipcRenderer} = require('electron')
ipcRenderer.on('repos-refreshed', (repos) => {
reposView.setState(repos)
})
from desktop.
Yeah, the messages would have go to through the the main process but you could do it all from the background process window.
Ah yeah, great call π
from desktop.
Thanks for the input everyone π
Gonna continue this discussion around some Real Code in #97.
from desktop.
Related Issues (20)
- 代η ζΎη€ΊεΊεδ½ε€ͺε°,δΈδΈθ½θ°,εΈζ解ε³.
- Invalid (C#) color styling when using decimal separators (underscores) in large numbers
- Please display actual commit dates in commit history HOT 1
- IntelliJ is not integrated anymore since Windows Version 3.3.6 (x64) HOT 16
- Canoot login on git lab with git hub account HOT 1
- Allow right click and view on GitHub on Pull Requests
- Stuck at Rebasing branch HOT 1
- README HOT 2
- Ignore folder HOT 2
- Fetch timestamp displaying incorrectly HOT 5
- Program not showing up HOT 2
- Forgot email HOT 2
- "Friendly" time stamp gives wrong times for some commits
- inability to push codes from vs code terminal HOT 1
- The branch list doesn't render some branches if you use the scroll bar HOT 1
- Local Commit Problem HOT 2
- Cannot push origin, throws "Authentication failed". HOT 1
- GPG sign failure HOT 1
- "Unable to open shell" Diaglog to suggestion on how to open the "Shell Settings" dialog HOT 1
- Github Desktop swap commits between branches HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from desktop.