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

Thoughts on using Lore with Electron? #125

Open
dustintownsend opened this issue Aug 16, 2016 · 3 comments
Open

Thoughts on using Lore with Electron? #125

dustintownsend opened this issue Aug 16, 2016 · 3 comments

Comments

@dustintownsend
Copy link

Yesterday on YouTube I came across @jchansen presentation at the Phoenix ReactJS meetup. I was originally watching the Redux Saga one and ended up watching the Architecture one and learned about Lore.

I'm curious if anyone here had any thoughts on attempting to use Lore with an Electron project?

@jchansen
Copy link
Contributor

@bringking have you ever used Electron? I'm going to provide my thoughts below, but feel free to weigh in if you have a better answer.

@dustintownsend I haven't used Electron yet, but it does pique my interest.

Personally, I don't have real experience developing for native mobile or modern day Mac or Windows, in part due to a lack of genuine need, and in part because I feel browser-based development already has enough complexity without trying to split my focus across a second or third technology set.

That being said, I'm very interested in technologies like React Native and Electron that have the potential to create a universal development experience, and I expect to shift my focus in that direction once I'm satisfied that Lore solves all my browser-centric development concerns.

So while I haven't used Electron personally (yet) I can at least weigh in on where I think the problem areas might be in getting Lore to work with it:

  1. The first potential issue is that Lore makes an assumption that it's running in a browser, and consequently there's a mount method in lore core that is responsible for mounting the application to the DOM through ReactDOM.render and document.getElementById. If Electron has a different strategy for mounting your application, this function would be a problem. There's been discussion about pulling it out though, to allow someone to modify the mounting strategy, or at least change which DOM node the application is mounted to, or just have more control over the mounting process in general, like using a development version of ReactDOM that has a different interface.
  2. The second potential issue might have to do with Webpack (i.e. the build process Lore is somewhat tied to). If Electron has it's own build process, that could be a problem. There are places in Lore core that use require.context (part of Webpack) to pull in files at build time that the framework didn't create (like custom Models and Actions) and so can't explicitly require until run-time. If Electron follows a different build process, that's probably an issue. On the other hand, the tests don't use Webpack to require files, they use Node, so that part of the code has at least been abstracted out to be optional and/or overridable as a necessity for testing.
  3. With respect to AJAX communication, Lore uses axios, which is an AJAX library designed to work on both the browser and server side. If that library works in Electron, then the API communication should work (?).

Other than that, Lore is a pretty straight implementation of React, Redux and React-Router, so if those technologies work in Electron (such as some of the Redux examples) I can't think of anything else in the framework would cause problems.

If you do try it out, I'd be curious to hear your thoughts, or how quickly it blew up : ) And when I do try Electron out, I'll weigh in again with more specific and concrete feedback, or post an example app if I can get it to work (even if it's only on a branch).

@bringking
Copy link
Contributor

@jchansen I haven't used Electron, but from what I understand about it, it uses a Chromium window for the UI, so can't think of a reason why Lore wouldn't be a drop in for an Electron project.

@dustintownsend
Copy link
Author

I don't think any of those will be an issue with Electron. I'm currently trying to fully understand the workings of webpack, but there are examples of using webpack with Electron. From my current understanding I would assume it would just be a matter of getting the webpack config set-up correctly. The only issue I've run into with webpack and electron is properly handling native modules, since they need to be built for the target platform (windows, osx, linux, 32/64bit). But, I think that is working with adding those modules to the exclude in webpack config.

Electron is basically two components. The renderer and the main process. The renderer is the view/browser and is Chromium! The main process is just a standard node process. One major difference from the browser developer would be you can actually write node code in the renderer process, but that can be turned off as well.

My background is opposite of you basically. I come from a desktop background (and some iOS/swift for the last year). After 9 or 10 years I was ready to get off of .NET and start using some of the more interesting things I've seen from Node and JS. But, we still have a need for desktop apps (in an enterprise setting). So, I took a risk recently to update one of our applications from .NET to Electron. So far it is going well, but I see a need for something like Lore to reduce the boilerplate. And I really like CLI interfaces for generating code. I recently tried the create-react-app generator which I though was pretty cool. It made it easier for me to experiment with React.

For now I'm just studying your code and trying to learn as much as I can from it. I will attempt to incorporate it into Electron and see how it works out at some point. Right now I'm working on learning and setting up Redux Saga and that is taking up a lot of my brain power.

For some reference you can see this nice Electron boilerplate for using React, redux, and webpack! https://github.com/chentsulin/electron-react-boilerplate
I have a fork of that working on using a different packager and I'm working on making my own boilerplate based on the production app I'm developing. I'm calling that Volt
https://github.com/dustintownsend/volt I think once I get past the webpack integration into my project and setup for volt I will attempt to bring in Lore at that point.

Exciting stuff from you guys. Thanks for sharing. I look forward to following and contributing to Lore.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants