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

Use inversify to build the example electron app #4869

Closed
wants to merge 1 commit into from

Conversation

paul-marechal
Copy link
Member

Every new logic that should happen in the Electron main process
currently has to be written inside the generators. This is difficult to
extend.

This commit refactorize the electron-main.js script to use inversify
in order to customize the logic happening when launching an electron
application.

Signed-off-by: Paul Maréchal [email protected]


This should begin to align Electron application development with the frontend/backend extensions.

@paul-marechal paul-marechal added electron issues related to the electron target quality issues related to code and application quality labels Apr 10, 2019
@paul-marechal paul-marechal force-pushed the mp/electron-inversified branch from a18fd67 to d976534 Compare April 10, 2019 19:44
@paul-marechal paul-marechal requested a review from thegecko April 10, 2019 19:45
Copy link
Member

@thegecko thegecko left a comment

Choose a reason for hiding this comment

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

Runs locally and LGTM. Probably needs another pair of eyes on it as I'm not too learned in this area of Theia :)

@akosyakov
Copy link
Member

I will have a look later today, had to fix theia-apps next images first, second time this week 🙈

@akosyakov
Copy link
Member

Wrapping communications between main and renderer processes into JSON-RPC services would be cool next step. Then we will have aligned arch for all processes.

@paul-marechal
Copy link
Member Author

paul-marechal commented Apr 12, 2019

Wrapping communications between main and renderer processes into JSON-RPC services would be cool next step. Then we will have aligned arch for all processes.

Do you want me to set that up in this PR or would it be a follow up?

@akosyakov
Copy link
Member

@marechal-p separately

@paul-marechal paul-marechal force-pushed the mp/electron-inversified branch from d976534 to cfaed14 Compare April 15, 2019 11:37
@kittaakos kittaakos removed their request for review April 16, 2019 11:18
@paul-marechal paul-marechal force-pushed the mp/electron-inversified branch from cfaed14 to c6347b2 Compare April 24, 2019 15:01
@paul-marechal
Copy link
Member Author

@akosyakov the PR is already approved but since you had comment I am waiting for yours.

@akosyakov
Copy link
Member

@kittaakos Could you have a look that control flow is still good for bundled electron apps?

@akosyakov
Copy link
Member

@marechal-p sorry i would need more time with this code which i don't have now (support of VS Code extension is more important). Looking at the code i don't think contribution points are properly designed. Usually we have an app which does start up and then lifecycle contributions allow to participate, in this PR it seems that lifecycle contribution does the startup like creating windows, making sure that state is stored. It should not be like that.

@kittaakos
Copy link
Contributor

@kittaakos Could you have a look that control flow is still good for bundled electron apps?

I could, but you'll have to wait till next week though.

@paul-marechal
Copy link
Member Author

sorry i would need more time with this code which i don't have now (support of VS Code extension is more important).

Indeed, I just didn't know who else to ping that would like to have a look at that, I know you made the setup for frontend/backend so I figured you'd have comments.

Looking at the code i don't think contribution points are properly designed.

Ah yes, I wasn't so sure how to handle it. My original idea was to allow clients to almost entirely define the way they want to handle the lifecycle for the electron application, without imposing ours.

I can see how to improve that.

I could, but you'll have to wait till next week though.

Perfect, thank you :)

@paul-marechal paul-marechal force-pushed the mp/electron-inversified branch from fac8de5 to 96215a6 Compare April 26, 2019 22:25
@paul-marechal paul-marechal force-pushed the mp/electron-inversified branch 2 times, most recently from 5a1704c to 2048a26 Compare April 29, 2019 13:49
@paul-marechal
Copy link
Member Author

@kittaakos I am not 100% convinced that the lifecycle management is perfect, but maybe you have some advices/opinions already?

Copy link
Contributor

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

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

Wow, the startup is way faster than before. 👍

I have added a few remarks here and there; I am happy to try it again if you have any updates/changes. If you have any questions, or you disagree with any of my comments, please let me know.

@akosyakov
Copy link
Member

@kittaakos could you finish the review please? I won't have time to have a look and don't want to stay in the way much.

@marechal-p let's go with whatever you have now and refactor it later then

@kittaakos
Copy link
Contributor

@kittaakos could you finish the review please?

👍 Sure.

@vince-fugnitto
Copy link
Member

@marechal-p do you still plan on continuing your work on the PR?

I think it's really interesting and will also make it a lot easier for devs in the future to update the Electron part of the application while also improving startup time :)

@paul-marechal
Copy link
Member Author

I mean, I was pretty much done. Unless someone sees something missing.

I can rebase.

Every new logic that should happen in the Electron main process
currently has to be written inside the generators. This is difficult to
extend.

This commit refactorize the `electron-main.js` script to use inversify
in order to customize the logic happening when launching an electron
application.

Signed-off-by: Paul Maréchal <[email protected]>
@paul-marechal paul-marechal force-pushed the mp/electron-inversified branch from 9f8c716 to b0759f9 Compare July 25, 2019 15:53
event.preventDefault();
let preventStop = false;
// Ask all opened windows whether they want to prevent the \`close\` event or not.
for (const window of electron.BrowserWindow.getAllWindows()) {
Copy link
Member Author

Choose a reason for hiding this comment

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

I rebased using gitpod, but I think I should test that locally, really don't know where to move this code right now.

@paul-marechal
Copy link
Member Author

The use case was raised internally to be able to customize the electron main process.

According to @akosyakov earlier comments, I am rewriting a new PR which will connect electron-renderer processes and the electron-main process using our JsonRpcProxies.

Changes should be better than the current PR, so I will close this and open a new one when ready.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
electron issues related to the electron target quality issues related to code and application quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants