Skip to content
This repository has been archived by the owner on Aug 23, 2018. It is now read-only.

make Elm variable available on this scope. #154

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ryan-haskell
Copy link

Heyo Evan

I was trying to use Elm in an Electron app and I ran into a weird error where the Elm variable was not defined.

I followed the tutorial at https://guide.elm-lang.org/interop/javascript.html like a noob.

Changing the generated file from var Elm = {} to this.Elm = {} gave me access to the variable, and my problems were resolved.

Likely, I goofed something up, but it's possible I finally made a contribution to Elm, and "wrote my first line" of Haskell code.

I'll attach a link to the repo so you can easily replicate the error.

@process-bot
Copy link

Thanks for the pull request! Make sure it satisfies this checklist. My human colleagues will appreciate it!

Here is what to expect next, and if anyone wants to comment, keep these things in mind.

@ryan-haskell
Copy link
Author

Repo with issue:
https://github.com/RyanNHG/first-electron-app

@ryan-haskell ryan-haskell changed the title make Elm variable available on window scope. make Elm variable available on this scope. Feb 28, 2017
@ryan-haskell
Copy link
Author

ryan-haskell commented Feb 28, 2017

A workaround is shown here: https://github.com/mdgriffith/elm-electron-todomvc/blob/master/index.html

Where the line window.Elm = require('./elm.js') is used to make the Elm object globally available.

Choose your own adventure:

  • "Adding this.Elm to elm-make!"
  • "Adding window.Elm = require('./elm.js') to the guide for people using electron!"
  • "Neither, you're drunk Ryan, go home!"

Let me know what you think.

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

Successfully merging this pull request may close these issues.

2 participants