-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added improved System control and IPC event handling
- Loading branch information
Showing
10 changed files
with
88 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// src/main/BaseComponent.js | ||
class BaseComponent { | ||
constructor() { | ||
// Common properties of components can be initialized here | ||
} | ||
|
||
// Common methods shared by all components | ||
initialize() { | ||
// Initialization code common to all components | ||
} | ||
} | ||
|
||
module.exports = BaseComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// src/main/BaseSystem.js | ||
class BaseSystem { | ||
constructor(name) { | ||
this.name = name; | ||
console.log(`[${this.name}] System created`); | ||
} | ||
|
||
initialize() { | ||
// Initialization code common to all systems | ||
} | ||
|
||
log(message) { | ||
console.log(`[${this.name}] ${message}`); | ||
} | ||
} | ||
|
||
module.exports = BaseSystem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// src/main/EventComponent.js | ||
const BaseComponent = require('./BaseComponent'); | ||
|
||
class EventComponent extends BaseComponent { | ||
constructor(type, data) { | ||
super(); | ||
this.type = type; | ||
this.data = data; | ||
} | ||
|
||
dispatch(ipcMain) { | ||
ipcMain.emit(this.type, this.data); | ||
} | ||
} | ||
|
||
module.exports = EventComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,4 @@ app.on('window-all-closed', () => { | |
if (process.platform !== 'darwin') { | ||
app.quit(); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
// src/renderer/RendererBaseSystem.js | ||
export default class RendererBaseSystem { | ||
constructor(name) { | ||
this.name = name; | ||
console.log(`[${this.name}] System created`); | ||
} | ||
|
||
initialize() { | ||
// Initialization code common to all renderer systems | ||
} | ||
|
||
log(message) { | ||
console.log(`[${this.name}] ${message}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
// src/renderer/RendererEventSystem.js | ||
export default class RendererEventSystem { | ||
constructor() { | ||
console.log("[R-EVENT-SYSTEM] created"); | ||
this.initializeIpcListeners(); | ||
} | ||
import RendererBaseSystem from './RendererBaseSystem'; | ||
|
||
initializeIpcListeners() { | ||
window.api.receive('main-event-response', (data) => { | ||
console.log('[R-EVENT-SYSTEM] Received response from main process:', data); | ||
}); | ||
} | ||
export default class RendererEventSystem extends RendererBaseSystem { | ||
constructor() { | ||
super('R-EVENT-SYSTEM'); | ||
this.initializeIpcListeners(); | ||
} | ||
|
||
test() { | ||
console.log('[R-EVENT-SYSTEM] test function executed'); | ||
window.api.send('renderer-event', 'Hello to Better Prompts'); | ||
} | ||
initializeIpcListeners() { | ||
window.api.receive('main-event-response', (data) => { | ||
this.log('Received response from main process: ' + data); | ||
}); | ||
} | ||
|
||
test() { | ||
this.log('test function executed'); | ||
window.api.send('renderer-event', 'Hello to Better Prompts'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters