Skip to content

Enhancement: Allow Electron to use browser version of Parse JS SDK. #193

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

Closed
typhonrt opened this issue Jan 28, 2016 · 4 comments
Closed

Comments

@typhonrt
Copy link

@andrewimm

I am now supporting easy integration w/ Electron for backbone-parse-es6 via JSPM / SystemJS and typhonjs-core-gulptasks. An Electron desktop demo version of the canonical TODOS app is available via electron-backbone-parse-es6-todos-improved.

Since Electron is a hybrid Node / browser environment Parse thinks it's running in Node though it can run perfectly fine in browser mode in Electron.

In CoreManager config.IS_NODE is set here on lines 113-115

If one changes this to the following then Parse will run in browser mode in Electron:

  IS_NODE: (typeof process !== 'undefined' &&
            !!process.versions &&
            !process.versions.electron &&
            !!process.versions.node),

Everything else works after that. I can't see a way of setting IS_NODE to false before ParseUser and ParseObject set module private variables based on IS_NODE. This occurs on import of Parse before any chance to invoke the API or access Parse.CoreManager is possible. IE one can't call Parse.CoreManager.set('IS_NODE', false); before affected areas of code run.

Can you recommend a way forward for allowing Parse to run in browser mode in Electron?

@andrewimm
Copy link
Contributor

@typhonrt we're considering a more verbose initialization API, as seen here: parse-community/Parse-SDK-iOS-OSX#570
We haven't committed to any formats on the JS SDK, but the ability to set these types of flags might be handy.
In the meantime, if you wanted to submit a PR for Electron support, I'd be happy to take a look at it

@typhonjs
Copy link

I was able to solve this, but only for backbone-parse-es6.

I provide a helper module to init parse from a config file with typhonjs-core-parse-init. By changing this to CJS from ES6 I am able to manipulate CoreManager before Parse is imported / required.

That certainly is a cool feature of JSPM / SystemJS insofar that you can selectively load modules as any type and even in a 99.9% ES6 codebase pull in a CJS module to get around ES6 hoisted imports when necessary.

So folks who want to see an Electron demo w/ Parse & Backbone check out: electron-backbone-parse-es6-todos-improved.


Perhaps the general solution for Parse is moving this CoreManager access in ParseObject to the Parse.initialize method.

In ParseUser instead of setting a module private variable perhaps directly access Parse.CoreManager.get('IS_NODE') where canUseCurrentUser is used.


While I have your attention @andrewimm could you please comment on the outstanding deserialization issue that I'm waiting on for your response. I've outlined a solution in #144

@andrewimm
Copy link
Contributor

Resolved in 1.7.1

@typhonrt
Copy link
Author

Sounds good @andrewimm ! Do take a look at the solution I outlined in #144 If that is agreeable to you and you'll timely review a PR I'll make the changes.

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

No branches or pull requests

2 participants